diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 900b6f70a..43b7e161a 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -164,6 +164,9 @@ func (a *{{.Service.Name}}API) {{.PascalName}}AndWait(ctx context.Context{{if .R // This method is generated by Databricks SDK Code Generator. func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{.Pagination.Entity.PascalName}}, error) { {{if .Pagination.MultiRequest}}var results []{{.Pagination.Entity.PascalName}} + {{if .RawRequest}}listing := {{.RawRequest.PascalName}}{ {{range .Request.Fields }} + {{.PascalName}}: request.{{.PascalName}},{{end}} + }{{end}} {{ if .Pagination.Limit -}} var totalCount {{template "type" .Pagination.Limit.Entity}} = 0 {{ end -}} @@ -172,9 +175,9 @@ func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Reque // deduplicate items that may have been added during iteration seen := map[{{template "type" .IdentifierField.Entity}}]bool{} {{end}}{{if eq .Pagination.Increment 1 -}} - request.{{.Pagination.Offset.PascalName}} = 1 // start iterating from the first page + listing.{{.Pagination.Offset.PascalName}} = 1 // start iterating from the first page {{end}}for { - response, err := a.impl.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) + response, err := a.impl.{{.PascalName}}(ctx{{if .Request}}, listing{{end}}) if err != nil { return nil, err } @@ -203,19 +206,20 @@ func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Reque if response.NextPage == nil { break } - request = *response.NextPage + // cluster events API returns next page information as part of the result + listing = *response.NextPage {{- else if .Pagination.Token -}} - request.{{.Pagination.Token.PollField.PascalName}} = response.{{.Pagination.Token.Bind.PascalName}} + listing.{{.Pagination.Token.PollField.PascalName}} = response.{{.Pagination.Token.Bind.PascalName}} if response.{{.Pagination.Token.Bind.PascalName}} == "" { break } {{- else if eq .Pagination.Increment 1 -}} - request.{{.Pagination.Offset.PascalName}}++ + listing.{{.Pagination.Offset.PascalName}}++ {{- else -}} - request.{{.Pagination.Offset.PascalName}} += {{template "type" .Pagination.Offset.Entity}}(len(response.{{.Pagination.Results.PascalName}})) + listing.{{.Pagination.Offset.PascalName}} += {{template "type" .Pagination.Offset.Entity}}(len(response.{{.Pagination.Results.PascalName}})) {{- end}} {{ if .Pagination.Limit -}} - limit := request.{{.Pagination.Limit.PascalName}} + limit := listing.{{.Pagination.Limit.PascalName}} if limit > 0 && totalCount >= limit { break } @@ -283,7 +287,7 @@ func (a *{{.Service.Name}}API) GetBy{{range .NamedIdMap.NamePath}}{{.PascalName} {{end}}{{if .Shortcut}} {{.Comment "// " 80}} func (a *{{.Service.Name}}API) {{.Shortcut.PascalName}}(ctx context.Context{{range .Shortcut.Params}}, {{.CamelName}} {{template "type" .Entity}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{template "type" .Response}}{{end}}, error){{else}}error{{end}} { - return a.impl.{{.PascalName}}(ctx, {{.Request.PascalName}}{ + return a.impl.{{.PascalName}}(ctx, {{.RealRequest.PascalName}}{ {{- range .Shortcut.Params}} {{.PascalName}}: {{.CamelName}},{{end}} }) diff --git a/.codegen/impl.go.tmpl b/.codegen/impl.go.tmpl index 695249eb6..577c99d6c 100644 --- a/.codegen/impl.go.tmpl +++ b/.codegen/impl.go.tmpl @@ -18,13 +18,13 @@ type {{.CamelName}}Impl struct { } {{range .Methods}} -func (a *{{.Service.CamelName}}Impl) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{template "type" .Response}}{{end}}, error){{else}}error{{end}} { +func (a *{{.Service.CamelName}}Impl) {{.PascalName}}(ctx context.Context{{if .RealRequest}}, request {{.RealRequest.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{template "type" .Response}}{{end}}, error){{else}}error{{end}} { {{if .Response}}var {{.Response.CamelName}} {{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}{{template "type" .Response}}{{end}} {{end -}} path := {{if .PathParts -}} fmt.Sprintf("{{range .PathParts}}{{.Prefix}}{{if or .Field .IsAccountId}}%v{{end}}{{ end }}"{{ range .PathParts }}{{if .Field}}, request.{{.Field.PascalName}}{{ else if .IsAccountId }}, a.client.ConfiguredAccountID(){{end}}{{ end }}) {{- else}}"{{.Path}}"{{end}} - err := a.client.Do(ctx, http.Method{{.TitleVerb}}, path, {{if .Request}}request{{else}}nil{{end}}, {{if .Response}}&{{.Response.CamelName}}{{else}}nil{{end}}) + err := a.client.Do(ctx, http.Method{{.TitleVerb}}, path, {{if .RealRequest}}request{{else}}nil{{end}}, {{if .Response}}&{{.Response.CamelName}}{{else}}nil{{end}}) return {{if .Response}}{{if not .Response.ArrayValue}}&{{end}}{{.Response.CamelName}}, {{end}}err } {{end -}} diff --git a/.codegen/interface.go.tmpl b/.codegen/interface.go.tmpl index ddf209cf4..c5bca17c6 100644 --- a/.codegen/interface.go.tmpl +++ b/.codegen/interface.go.tmpl @@ -17,7 +17,7 @@ type {{.PascalName}}Service interface { // // Use {{.PascalName}}All() to get all {{.Pagination.Entity.PascalName}} instances{{if .Pagination.MultiRequest}}, which will iterate over every result page.{{end}} {{- end}} - {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{template "type" .Response}}{{end}}, error){{else}}error{{end}} + {{.PascalName}}(ctx context.Context{{if .RealRequest}}, request {{.RealRequest.PascalName}}{{end}}) {{if .Response}}({{if .Response.ArrayValue}}[]{{.Response.ArrayValue.PascalName}}{{else}}*{{template "type" .Response}}{{end}}, error){{else}}error{{end}} {{end -}} } diff --git a/openapi/code/method.go b/openapi/code/method.go index cd3fca0ad..8838b2238 100644 --- a/openapi/code/method.go +++ b/openapi/code/method.go @@ -20,6 +20,8 @@ type Method struct { PathParts []PathPart // Request type representation Request *Entity + // Request for listing + RawRequest *Entity // Response type representation Response *Entity EmptyResponseName Named @@ -209,6 +211,15 @@ func (m *Method) Wait() *Wait { } } +// Returns either RawRequest used for fetching individual pages of data +// or a more friendly request, if it's there. +func (m *Method) RealRequest() *Entity { + if m.RawRequest != nil { + return m.RawRequest + } + return m.Request +} + // Pagination returns definition for possibly multi-request result iterator func (m *Method) Pagination() *Pagination { if m.pagination == nil { @@ -221,12 +232,12 @@ func (m *Method) Pagination() *Pagination { var token *Binding if m.pagination.Token != nil { token = &Binding{ // reuse the same datastructure as for waiters - PollField: m.Request.Field(m.pagination.Token.Request), + PollField: m.RawRequest.Field(m.pagination.Token.Request), Bind: m.Response.Field(m.pagination.Token.Response), } } - offset := m.Request.Field(m.pagination.Offset) - limit := m.Request.Field(m.pagination.Limit) + offset := m.RawRequest.Field(m.pagination.Offset) + limit := m.RawRequest.Field(m.pagination.Limit) results := m.Response.Field(m.pagination.Results) if results == nil { panic(fmt.Errorf("invalid results field '%v': %s", diff --git a/openapi/code/service.go b/openapi/code/service.go index 84825c33d..3973bd9ae 100644 --- a/openapi/code/service.go +++ b/openapi/code/service.go @@ -298,12 +298,14 @@ func (svc *Service) newMethod(verb, path string, params []openapi.Parameter, op } idFieldPath = idField } + request, listingRequest := svc.withPaginationFieldsRemoved(request, op.Pagination) return &Method{ Named: Named{name, description}, Service: svc, Verb: strings.ToUpper(verb), Path: path, Request: request, + RawRequest: listingRequest, PathParts: svc.paramPath(path, request, params), Response: response, EmptyResponseName: emptyResponse, @@ -317,6 +319,89 @@ func (svc *Service) newMethod(verb, path string, params []openapi.Parameter, op } } +// remove pagination fields without clear semantics for iterators +func (svc *Service) withPaginationFieldsRemoved(req *Entity, pg *openapi.Pagination) (*Entity, *Entity) { + if req == nil { + return nil, nil + } + if svc.Name == "Clusters" && req.CamelName() == "getEvents" { + // edge case: cluster events performs listing through POST, not GET. + // all other listing requests entities are synthesized. + return req, req + } + if pg == nil || pg.Inline { + return req, nil + } + if pg.Offset == "" && + pg.Limit == "" && + pg.Increment == 0 && + pg.Token == nil && + pg.Results != "" { + return req, nil + } + listing := &Entity{ + Named: Named{ + Name: req.PascalName(), + Description: req.Description, + }, + Package: req.Package, + RequiredOrder: req.RequiredOrder, + fields: map[string]*Field{}, + } + var requiresModification bool + for _, v := range req.fields { + field := v + var nextToken string + if pg.Token != nil { + nextToken = pg.Token.Request + } + switch field.Name { + case pg.Limit, pg.Offset, nextToken: + requiresModification = true + continue + } + listing.fields[field.Name] = field + } + if !requiresModification { + panic(fmt.Errorf("incorrect type detected: %s", req.FullName())) + } + if svc.Name == "Jobs" { + // add generation for client-side maximum number of results during iteration. + // platform already implements this field for part of the APIs and it's + // consistently named as max_results everywhere. Perhaps we should + // rename "limit" to "max_results" in Jobs and add that to Dashboards and + // Queries as well, as we have exactly the same problem on big workspaces. + pg.Limit = "limit" + listing.fields["limit"] = &Field{ + Named: Named{ + Name: "limit", + Description: "limit maximum number of results on the client side", + }, + Of: listing, + IsJson: false, + IsQuery: false, + IsPath: false, + Entity: &Entity{ + IsInt: true, + }, + } + } + if len(listing.fields) == 0 { + // there is no fields left. + return nil, req + } + oldName := req.Name + _, needsRename := svc.Package.types[oldName] + if needsRename { + newName := strings.TrimSuffix(req.CamelName(), "Request") + "Internal" + req.Name = newName + req.Description = "For internal use only" + delete(svc.Package.types, oldName) + svc.Package.types[newName] = req + } + return svc.Package.define(listing), req +} + func (svc *Service) HasWaits() bool { for _, v := range svc.methods { if v.wait != nil { diff --git a/service/catalog/api.go b/service/catalog/api.go index 5e61dd7f3..f5fdde020 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -1703,9 +1703,15 @@ func (a *TablesAPI) GetByFullName(ctx context.Context, fullName string) (*TableI // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { var results []TableInfo + listing := ListTablesInternal{ + CatalogName: request.CatalogName, + IncludeDeltaMetadata: request.IncludeDeltaMetadata, + MaxResults: request.MaxResults, + SchemaName: request.SchemaName, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.List(ctx, request) + response, err := a.impl.List(ctx, listing) if err != nil { return nil, err } @@ -1715,7 +1721,7 @@ func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]T for _, v := range response.Tables { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } @@ -1793,9 +1799,15 @@ func (a *TablesAPI) GetByName(ctx context.Context, name string) (*TableInfo, err // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesRequest) ([]TableSummary, error) { var results []TableSummary + listing := ListSummariesInternal{ + CatalogName: request.CatalogName, + MaxResults: request.MaxResults, + SchemaNamePattern: request.SchemaNamePattern, + TableNamePattern: request.TableNamePattern, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.ListSummaries(ctx, request) + response, err := a.impl.ListSummaries(ctx, listing) if err != nil { return nil, err } @@ -1805,7 +1817,7 @@ func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesR for _, v := range response.Tables { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } diff --git a/service/catalog/impl.go b/service/catalog/impl.go index 7d0f7cb75..6adf2ec9f 100755 --- a/service/catalog/impl.go +++ b/service/catalog/impl.go @@ -530,14 +530,14 @@ func (a *tablesImpl) Get(ctx context.Context, request GetTableRequest) (*TableIn return &tableInfo, err } -func (a *tablesImpl) List(ctx context.Context, request ListTablesRequest) (*ListTablesResponse, error) { +func (a *tablesImpl) List(ctx context.Context, request ListTablesInternal) (*ListTablesResponse, error) { var listTablesResponse ListTablesResponse path := "/api/2.1/unity-catalog/tables" err := a.client.Do(ctx, http.MethodGet, path, request, &listTablesResponse) return &listTablesResponse, err } -func (a *tablesImpl) ListSummaries(ctx context.Context, request ListSummariesRequest) (*ListTableSummariesResponse, error) { +func (a *tablesImpl) ListSummaries(ctx context.Context, request ListSummariesInternal) (*ListTableSummariesResponse, error) { var listTableSummariesResponse ListTableSummariesResponse path := "/api/2.1/unity-catalog/table-summaries" err := a.client.Do(ctx, http.MethodGet, path, request, &listTableSummariesResponse) diff --git a/service/catalog/interface.go b/service/catalog/interface.go index 730658f71..a51a05ccd 100755 --- a/service/catalog/interface.go +++ b/service/catalog/interface.go @@ -681,7 +681,7 @@ type TablesService interface { // array. // // Use ListAll() to get all TableInfo instances, which will iterate over every result page. - List(ctx context.Context, request ListTablesRequest) (*ListTablesResponse, error) + List(ctx context.Context, request ListTablesInternal) (*ListTablesResponse, error) // List table summaries. // @@ -700,7 +700,7 @@ type TablesService interface { // array. // // Use ListSummariesAll() to get all TableSummary instances, which will iterate over every result page. - ListSummaries(ctx context.Context, request ListSummariesRequest) (*ListTableSummariesResponse, error) + ListSummaries(ctx context.Context, request ListSummariesInternal) (*ListTableSummariesResponse, error) // Update a table owner. // diff --git a/service/catalog/model.go b/service/catalog/model.go index 9a57943bf..5f7aae569 100755 --- a/service/catalog/model.go +++ b/service/catalog/model.go @@ -1600,8 +1600,8 @@ type ListStorageCredentialsResponse struct { StorageCredentials []StorageCredentialInfo `json:"storage_credentials,omitempty"` } -// List table summaries -type ListSummariesRequest struct { +// For internal use only +type ListSummariesInternal struct { // Name of parent catalog for tables of interest. CatalogName string `json:"-" url:"catalog_name"` // Maximum number of tables to return (page length). Defaults to 10000. @@ -1616,6 +1616,20 @@ type ListSummariesRequest struct { TableNamePattern string `json:"-" url:"table_name_pattern,omitempty"` } +// List table summaries +type ListSummariesRequest struct { + // Name of parent catalog for tables of interest. + CatalogName string `json:"-" url:"catalog_name"` + // Maximum number of tables to return (page length). Defaults to 10000. + MaxResults int `json:"-" url:"max_results,omitempty"` + // A sql LIKE pattern (% and _) for schema names. All schemas will be + // returned if not set or empty. + SchemaNamePattern string `json:"-" url:"schema_name_pattern,omitempty"` + // A sql LIKE pattern (% and _) for table names. All tables will be returned + // if not set or empty. + TableNamePattern string `json:"-" url:"table_name_pattern,omitempty"` +} + // List system schemas type ListSystemSchemasRequest struct { // The ID for the metastore in which the system schema resides. @@ -1634,8 +1648,8 @@ type ListTableSummariesResponse struct { Tables []TableSummary `json:"tables,omitempty"` } -// List tables -type ListTablesRequest struct { +// For internal use only +type ListTablesInternal struct { // Name of parent catalog for tables of interest. CatalogName string `json:"-" url:"catalog_name"` // Whether delta metadata should be included in the response. @@ -1653,6 +1667,23 @@ type ListTablesRequest struct { SchemaName string `json:"-" url:"schema_name"` } +// List tables +type ListTablesRequest struct { + // Name of parent catalog for tables of interest. + CatalogName string `json:"-" url:"catalog_name"` + // Whether delta metadata should be included in the response. + IncludeDeltaMetadata bool `json:"-" url:"include_delta_metadata,omitempty"` + // Maximum number of tables to return (page length). If not set, all + // accessible tables in the schema are returned. If set to: + // + // * greater than 0, page length is the minimum of this value and a server + // configured value. * equal to 0, page length is set to a server configured + // value. * lesser than 0, invalid parameter error. + MaxResults int `json:"-" url:"max_results,omitempty"` + // Parent schema of tables. + SchemaName string `json:"-" url:"schema_name"` +} + type ListTablesResponse struct { // Opaque token for pagination. Omitted if there are no more results. // page_token should be set to this value for fetching the next page. diff --git a/service/compute/api.go b/service/compute/api.go index 039290e6d..a423cf74d 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -585,10 +585,19 @@ func (a *ClustersAPI) EditAndWait(ctx context.Context, editCluster EditCluster, // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) { var results []ClusterEvent + listing := GetEvents{ + ClusterId: request.ClusterId, + EndTime: request.EndTime, + EventTypes: request.EventTypes, + Limit: request.Limit, + Offset: request.Offset, + Order: request.Order, + StartTime: request.StartTime, + } var totalCount int64 = 0 ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.Events(ctx, request) + response, err := a.impl.Events(ctx, listing) if err != nil { return nil, err } @@ -603,8 +612,9 @@ func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]Clust if response.NextPage == nil { break } - request = *response.NextPage - limit := request.Limit + // cluster events API returns next page information as part of the result + listing = *response.NextPage + limit := listing.Limit if limit > 0 && totalCount >= limit { break } @@ -2045,9 +2055,12 @@ func (a *PolicyFamiliesAPI) GetByPolicyFamilyId(ctx context.Context, policyFamil // This method is generated by Databricks SDK Code Generator. func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamiliesRequest) ([]PolicyFamily, error) { var results []PolicyFamily + listing := ListPolicyFamiliesInternal{ + MaxResults: request.MaxResults, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.List(ctx, request) + response, err := a.impl.List(ctx, listing) if err != nil { return nil, err } @@ -2057,7 +2070,7 @@ func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamil for _, v := range response.PolicyFamilies { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } diff --git a/service/compute/impl.go b/service/compute/impl.go index 84aaa256e..105fd2296 100755 --- a/service/compute/impl.go +++ b/service/compute/impl.go @@ -434,7 +434,7 @@ func (a *policyFamiliesImpl) Get(ctx context.Context, request GetPolicyFamilyReq return &policyFamily, err } -func (a *policyFamiliesImpl) List(ctx context.Context, request ListPolicyFamiliesRequest) (*ListPolicyFamiliesResponse, error) { +func (a *policyFamiliesImpl) List(ctx context.Context, request ListPolicyFamiliesInternal) (*ListPolicyFamiliesResponse, error) { var listPolicyFamiliesResponse ListPolicyFamiliesResponse path := "/api/2.0/policy-families" err := a.client.Do(ctx, http.MethodGet, path, request, &listPolicyFamiliesResponse) diff --git a/service/compute/interface.go b/service/compute/interface.go index 8ffefac04..41ca68b36 100755 --- a/service/compute/interface.go +++ b/service/compute/interface.go @@ -584,5 +584,5 @@ type PolicyFamiliesService interface { // Retrieve a list of policy families. This API is paginated. // // Use ListAll() to get all PolicyFamily instances, which will iterate over every result page. - List(ctx context.Context, request ListPolicyFamiliesRequest) (*ListPolicyFamiliesResponse, error) + List(ctx context.Context, request ListPolicyFamiliesInternal) (*ListPolicyFamiliesResponse, error) } diff --git a/service/compute/model.go b/service/compute/model.go index 809d52d12..089ba6600 100755 --- a/service/compute/model.go +++ b/service/compute/model.go @@ -2991,14 +2991,20 @@ type ListPoliciesResponse struct { Policies []Policy `json:"policies,omitempty"` } -// List policy families -type ListPolicyFamiliesRequest struct { +// For internal use only +type ListPolicyFamiliesInternal struct { // The max number of policy families to return. MaxResults int64 `json:"-" url:"max_results,omitempty"` // A token that can be used to get the next page of results. PageToken string `json:"-" url:"page_token,omitempty"` } +// List policy families +type ListPolicyFamiliesRequest struct { + // The max number of policy families to return. + MaxResults int64 `json:"-" url:"max_results,omitempty"` +} + type ListPolicyFamiliesResponse struct { // A token that can be used to get the next page of results. If not present, // there are no more results to show. diff --git a/service/iam/model.go b/service/iam/model.go index 8aba542d8..fae12730a 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -776,7 +776,7 @@ type User struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks user ID. - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Name *Name `json:"name,omitempty"` diff --git a/service/jobs/api.go b/service/jobs/api.go index 29121b4a9..0f1ffe0d6 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -339,10 +339,16 @@ func (a *JobsAPI) GetRunOutputByRunId(ctx context.Context, runId int64) (*RunOut // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJob, error) { var results []BaseJob + listing := ListJobsInternal{ + ExpandTasks: request.ExpandTasks, + Limit: request.Limit, + Name: request.Name, + Offset: request.Offset, + } var totalCount int = 0 ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.List(ctx, request) + response, err := a.impl.List(ctx, listing) if err != nil { return nil, err } @@ -354,11 +360,11 @@ func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJ } count := int(len(response.Jobs)) totalCount += count - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } - limit := request.Limit + limit := listing.Limit if limit > 0 && totalCount >= limit { break } @@ -426,10 +432,21 @@ func (a *JobsAPI) GetBySettingsName(ctx context.Context, name string) (*BaseJob, // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]BaseRun, error) { var results []BaseRun + listing := ListRunsInternal{ + ActiveOnly: request.ActiveOnly, + CompletedOnly: request.CompletedOnly, + ExpandTasks: request.ExpandTasks, + JobId: request.JobId, + Limit: request.Limit, + Offset: request.Offset, + RunType: request.RunType, + StartTimeFrom: request.StartTimeFrom, + StartTimeTo: request.StartTimeTo, + } var totalCount int = 0 ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.ListRuns(ctx, request) + response, err := a.impl.ListRuns(ctx, listing) if err != nil { return nil, err } @@ -441,11 +458,11 @@ func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]B } count := int(len(response.Runs)) totalCount += count - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } - limit := request.Limit + limit := listing.Limit if limit > 0 && totalCount >= limit { break } diff --git a/service/jobs/impl.go b/service/jobs/impl.go index 6530ec243..d2b121bfb 100755 --- a/service/jobs/impl.go +++ b/service/jobs/impl.go @@ -88,14 +88,14 @@ func (a *jobsImpl) GetRunOutput(ctx context.Context, request GetRunOutputRequest return &runOutput, err } -func (a *jobsImpl) List(ctx context.Context, request ListJobsRequest) (*ListJobsResponse, error) { +func (a *jobsImpl) List(ctx context.Context, request ListJobsInternal) (*ListJobsResponse, error) { var listJobsResponse ListJobsResponse path := "/api/2.1/jobs/list" err := a.client.Do(ctx, http.MethodGet, path, request, &listJobsResponse) return &listJobsResponse, err } -func (a *jobsImpl) ListRuns(ctx context.Context, request ListRunsRequest) (*ListRunsResponse, error) { +func (a *jobsImpl) ListRuns(ctx context.Context, request ListRunsInternal) (*ListRunsResponse, error) { var listRunsResponse ListRunsResponse path := "/api/2.1/jobs/runs/list" err := a.client.Do(ctx, http.MethodGet, path, request, &listRunsResponse) diff --git a/service/jobs/interface.go b/service/jobs/interface.go index 29793786b..92bf7a397 100755 --- a/service/jobs/interface.go +++ b/service/jobs/interface.go @@ -98,14 +98,14 @@ type JobsService interface { // Retrieves a list of jobs. // // Use ListAll() to get all BaseJob instances, which will iterate over every result page. - List(ctx context.Context, request ListJobsRequest) (*ListJobsResponse, error) + List(ctx context.Context, request ListJobsInternal) (*ListJobsResponse, error) // List job runs. // // List runs in descending order by start time. // // Use ListRunsAll() to get all BaseRun instances, which will iterate over every result page. - ListRuns(ctx context.Context, request ListRunsRequest) (*ListRunsResponse, error) + ListRuns(ctx context.Context, request ListRunsInternal) (*ListRunsResponse, error) // Repair a job run. // diff --git a/service/jobs/model.go b/service/jobs/model.go index 53e4a51cb..f6b4f31e3 100755 --- a/service/jobs/model.go +++ b/service/jobs/model.go @@ -948,8 +948,8 @@ type JobsHealthRules struct { Rules []JobsHealthRule `json:"rules,omitempty"` } -// List jobs -type ListJobsRequest struct { +// For internal use only +type ListJobsInternal struct { // Whether to include task and cluster details in the response. ExpandTasks bool `json:"-" url:"expand_tasks,omitempty"` // The number of jobs to return. This value must be greater than 0 and less @@ -968,6 +968,22 @@ type ListJobsRequest struct { PageToken string `json:"-" url:"page_token,omitempty"` } +// List jobs +type ListJobsRequest struct { + // Whether to include task and cluster details in the response. + ExpandTasks bool `json:"-" url:"expand_tasks,omitempty"` + // limit maximum number of results on the client side + Limit int `json:"-"` + // A filter on the list based on the exact (case insensitive) job name. + Name string `json:"-" url:"name,omitempty"` + // The offset of the first job to return, relative to the most recently + // created job. + // + // Deprecated since June 2023. Use `page_token` to iterate through the pages + // instead. + Offset int `json:"-" url:"offset,omitempty"` +} + type ListJobsResponse struct { // If true, additional jobs matching the provided filter are available for // listing. @@ -980,8 +996,8 @@ type ListJobsResponse struct { PrevPageToken string `json:"prev_page_token,omitempty"` } -// List job runs -type ListRunsRequest struct { +// For internal use only +type ListRunsInternal struct { // If active_only is `true`, only active runs are included in the results; // otherwise, lists both active and completed runs. An active run is a run // in the `PENDING`, `RUNNING`, or `TERMINATING`. This field cannot be @@ -1021,6 +1037,42 @@ type ListRunsRequest struct { StartTimeTo int `json:"-" url:"start_time_to,omitempty"` } +// List job runs +type ListRunsRequest struct { + // If active_only is `true`, only active runs are included in the results; + // otherwise, lists both active and completed runs. An active run is a run + // in the `PENDING`, `RUNNING`, or `TERMINATING`. This field cannot be + // `true` when completed_only is `true`. + ActiveOnly bool `json:"-" url:"active_only,omitempty"` + // If completed_only is `true`, only completed runs are included in the + // results; otherwise, lists both active and completed runs. This field + // cannot be `true` when active_only is `true`. + CompletedOnly bool `json:"-" url:"completed_only,omitempty"` + // Whether to include task and cluster details in the response. + ExpandTasks bool `json:"-" url:"expand_tasks,omitempty"` + // The job for which to list runs. If omitted, the Jobs service lists runs + // from all jobs. + JobId int64 `json:"-" url:"job_id,omitempty"` + // limit maximum number of results on the client side + Limit int `json:"-"` + // The offset of the first run to return, relative to the most recent run. + // + // Deprecated since June 2023. Use `page_token` to iterate through the pages + // instead. + Offset int `json:"-" url:"offset,omitempty"` + // The type of runs to return. For a description of run types, see + // :method:jobs/getRun. + RunType ListRunsRunType `json:"-" url:"run_type,omitempty"` + // Show runs that started _at or after_ this value. The value must be a UTC + // timestamp in milliseconds. Can be combined with _start_time_to_ to filter + // by a time range. + StartTimeFrom int `json:"-" url:"start_time_from,omitempty"` + // Show runs that started _at or before_ this value. The value must be a UTC + // timestamp in milliseconds. Can be combined with _start_time_from_ to + // filter by a time range. + StartTimeTo int `json:"-" url:"start_time_to,omitempty"` +} + type ListRunsResponse struct { // If true, additional runs matching the provided filter are available for // listing. diff --git a/service/ml/api.go b/service/ml/api.go index 79414ff60..513487aa2 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -174,9 +174,14 @@ func (a *ExperimentsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Ge // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) { var results []FileInfo + listing := ListArtifactsInternal{ + Path: request.Path, + RunId: request.RunId, + RunUuid: request.RunUuid, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.ListArtifacts(ctx, request) + response, err := a.impl.ListArtifacts(ctx, listing) if err != nil { return nil, err } @@ -186,7 +191,7 @@ func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtif for _, v := range response.Files { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } @@ -201,9 +206,13 @@ func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtif // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) { var results []Experiment + listing := ListExperimentsInternal{ + MaxResults: request.MaxResults, + ViewType: request.ViewType, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.ListExperiments(ctx, request) + response, err := a.impl.ListExperiments(ctx, listing) if err != nil { return nil, err } @@ -213,7 +222,7 @@ func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExp for _, v := range response.Experiments { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } @@ -325,9 +334,15 @@ func (a *ExperimentsAPI) RestoreRun(ctx context.Context, request RestoreRun) err // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) { var results []Experiment + listing := SearchExperimentsInternal{ + Filter: request.Filter, + MaxResults: request.MaxResults, + OrderBy: request.OrderBy, + ViewType: request.ViewType, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.SearchExperiments(ctx, request) + response, err := a.impl.SearchExperiments(ctx, listing) if err != nil { return nil, err } @@ -337,7 +352,7 @@ func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request Searc for _, v := range response.Experiments { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } @@ -354,9 +369,16 @@ func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request Searc // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) ([]Run, error) { var results []Run + listing := SearchRunsInternal{ + ExperimentIds: request.ExperimentIds, + Filter: request.Filter, + MaxResults: request.MaxResults, + OrderBy: request.OrderBy, + RunViewType: request.RunViewType, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.SearchRuns(ctx, request) + response, err := a.impl.SearchRuns(ctx, listing) if err != nil { return nil, err } @@ -366,7 +388,7 @@ func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) for _, v := range response.Runs { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } @@ -628,9 +650,12 @@ func (a *ModelRegistryAPI) GetRegisteredModelPermissionsByRegisteredModelId(ctx // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModelsRequest) ([]Model, error) { var results []Model + listing := ListModelsInternal{ + MaxResults: request.MaxResults, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.ListModels(ctx, request) + response, err := a.impl.ListModels(ctx, listing) if err != nil { return nil, err } @@ -640,7 +665,7 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels for _, v := range response.RegisteredModels { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } @@ -670,9 +695,13 @@ func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, reques // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebhooksRequest) ([]RegistryWebhook, error) { var results []RegistryWebhook + listing := ListWebhooksInternal{ + Events: request.Events, + ModelName: request.ModelName, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.ListWebhooks(ctx, request) + response, err := a.impl.ListWebhooks(ctx, listing) if err != nil { return nil, err } @@ -682,7 +711,7 @@ func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebh for _, v := range response.Webhooks { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } @@ -711,9 +740,14 @@ func (a *ModelRegistryAPI) RenameModel(ctx context.Context, request RenameModelR // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) { var results []ModelVersion + listing := SearchModelVersionsInternal{ + Filter: request.Filter, + MaxResults: request.MaxResults, + OrderBy: request.OrderBy, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.SearchModelVersions(ctx, request) + response, err := a.impl.SearchModelVersions(ctx, listing) if err != nil { return nil, err } @@ -723,7 +757,7 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S for _, v := range response.ModelVersions { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } @@ -738,9 +772,14 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchModelsRequest) ([]Model, error) { var results []Model + listing := SearchModelsInternal{ + Filter: request.Filter, + MaxResults: request.MaxResults, + OrderBy: request.OrderBy, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.SearchModels(ctx, request) + response, err := a.impl.SearchModels(ctx, listing) if err != nil { return nil, err } @@ -750,7 +789,7 @@ func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchMo for _, v := range response.RegisteredModels { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } diff --git a/service/ml/impl.go b/service/ml/impl.go index 193941b1e..0e2e70996 100755 --- a/service/ml/impl.go +++ b/service/ml/impl.go @@ -89,14 +89,14 @@ func (a *experimentsImpl) GetRun(ctx context.Context, request GetRunRequest) (*G return &getRunResponse, err } -func (a *experimentsImpl) ListArtifacts(ctx context.Context, request ListArtifactsRequest) (*ListArtifactsResponse, error) { +func (a *experimentsImpl) ListArtifacts(ctx context.Context, request ListArtifactsInternal) (*ListArtifactsResponse, error) { var listArtifactsResponse ListArtifactsResponse path := "/api/2.0/mlflow/artifacts/list" err := a.client.Do(ctx, http.MethodGet, path, request, &listArtifactsResponse) return &listArtifactsResponse, err } -func (a *experimentsImpl) ListExperiments(ctx context.Context, request ListExperimentsRequest) (*ListExperimentsResponse, error) { +func (a *experimentsImpl) ListExperiments(ctx context.Context, request ListExperimentsInternal) (*ListExperimentsResponse, error) { var listExperimentsResponse ListExperimentsResponse path := "/api/2.0/mlflow/experiments/list" err := a.client.Do(ctx, http.MethodGet, path, request, &listExperimentsResponse) @@ -145,14 +145,14 @@ func (a *experimentsImpl) RestoreRun(ctx context.Context, request RestoreRun) er return err } -func (a *experimentsImpl) SearchExperiments(ctx context.Context, request SearchExperiments) (*SearchExperimentsResponse, error) { +func (a *experimentsImpl) SearchExperiments(ctx context.Context, request SearchExperimentsInternal) (*SearchExperimentsResponse, error) { var searchExperimentsResponse SearchExperimentsResponse path := "/api/2.0/mlflow/experiments/search" err := a.client.Do(ctx, http.MethodPost, path, request, &searchExperimentsResponse) return &searchExperimentsResponse, err } -func (a *experimentsImpl) SearchRuns(ctx context.Context, request SearchRuns) (*SearchRunsResponse, error) { +func (a *experimentsImpl) SearchRuns(ctx context.Context, request SearchRunsInternal) (*SearchRunsResponse, error) { var searchRunsResponse SearchRunsResponse path := "/api/2.0/mlflow/runs/search" err := a.client.Do(ctx, http.MethodPost, path, request, &searchRunsResponse) @@ -329,7 +329,7 @@ func (a *modelRegistryImpl) GetRegisteredModelPermissions(ctx context.Context, r return ®isteredModelPermissions, err } -func (a *modelRegistryImpl) ListModels(ctx context.Context, request ListModelsRequest) (*ListModelsResponse, error) { +func (a *modelRegistryImpl) ListModels(ctx context.Context, request ListModelsInternal) (*ListModelsResponse, error) { var listModelsResponse ListModelsResponse path := "/api/2.0/mlflow/registered-models/list" err := a.client.Do(ctx, http.MethodGet, path, request, &listModelsResponse) @@ -343,7 +343,7 @@ func (a *modelRegistryImpl) ListTransitionRequests(ctx context.Context, request return &listTransitionRequestsResponse, err } -func (a *modelRegistryImpl) ListWebhooks(ctx context.Context, request ListWebhooksRequest) (*ListRegistryWebhooks, error) { +func (a *modelRegistryImpl) ListWebhooks(ctx context.Context, request ListWebhooksInternal) (*ListRegistryWebhooks, error) { var listRegistryWebhooks ListRegistryWebhooks path := "/api/2.0/mlflow/registry-webhooks/list" err := a.client.Do(ctx, http.MethodGet, path, request, &listRegistryWebhooks) @@ -364,14 +364,14 @@ func (a *modelRegistryImpl) RenameModel(ctx context.Context, request RenameModel return &renameModelResponse, err } -func (a *modelRegistryImpl) SearchModelVersions(ctx context.Context, request SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) { +func (a *modelRegistryImpl) SearchModelVersions(ctx context.Context, request SearchModelVersionsInternal) (*SearchModelVersionsResponse, error) { var searchModelVersionsResponse SearchModelVersionsResponse path := "/api/2.0/mlflow/model-versions/search" err := a.client.Do(ctx, http.MethodGet, path, request, &searchModelVersionsResponse) return &searchModelVersionsResponse, err } -func (a *modelRegistryImpl) SearchModels(ctx context.Context, request SearchModelsRequest) (*SearchModelsResponse, error) { +func (a *modelRegistryImpl) SearchModels(ctx context.Context, request SearchModelsInternal) (*SearchModelsResponse, error) { var searchModelsResponse SearchModelsResponse path := "/api/2.0/mlflow/registered-models/search" err := a.client.Do(ctx, http.MethodGet, path, request, &searchModelsResponse) diff --git a/service/ml/interface.go b/service/ml/interface.go index 31f42b220..236ac8fe9 100755 --- a/service/ml/interface.go +++ b/service/ml/interface.go @@ -106,14 +106,14 @@ type ExperimentsService interface { // prefix.", // // Use ListArtifactsAll() to get all FileInfo instances, which will iterate over every result page. - ListArtifacts(ctx context.Context, request ListArtifactsRequest) (*ListArtifactsResponse, error) + ListArtifacts(ctx context.Context, request ListArtifactsInternal) (*ListArtifactsResponse, error) // List experiments. // // Gets a list of all experiments. // // Use ListExperimentsAll() to get all Experiment instances, which will iterate over every result page. - ListExperiments(ctx context.Context, request ListExperimentsRequest) (*ListExperimentsResponse, error) + ListExperiments(ctx context.Context, request ListExperimentsInternal) (*ListExperimentsResponse, error) // Log a batch. // @@ -208,7 +208,7 @@ type ExperimentsService interface { // Searches for experiments that satisfy specified search criteria. // // Use SearchExperimentsAll() to get all Experiment instances, which will iterate over every result page. - SearchExperiments(ctx context.Context, request SearchExperiments) (*SearchExperimentsResponse, error) + SearchExperiments(ctx context.Context, request SearchExperimentsInternal) (*SearchExperimentsResponse, error) // Search for runs. // @@ -217,7 +217,7 @@ type ExperimentsService interface { // Search expressions can use `mlflowMetric` and `mlflowParam` keys.", // // Use SearchRunsAll() to get all Run instances, which will iterate over every result page. - SearchRuns(ctx context.Context, request SearchRuns) (*SearchRunsResponse, error) + SearchRuns(ctx context.Context, request SearchRunsInternal) (*SearchRunsResponse, error) // Set experiment permissions. // @@ -376,7 +376,7 @@ type ModelRegistryService interface { // __max_results__. // // Use ListModelsAll() to get all Model instances, which will iterate over every result page. - ListModels(ctx context.Context, request ListModelsRequest) (*ListModelsResponse, error) + ListModels(ctx context.Context, request ListModelsInternal) (*ListModelsResponse, error) // List transition requests. // @@ -392,7 +392,7 @@ type ModelRegistryService interface { // Lists all registry webhooks. // // Use ListWebhooksAll() to get all RegistryWebhook instances, which will iterate over every result page. - ListWebhooks(ctx context.Context, request ListWebhooksRequest) (*ListRegistryWebhooks, error) + ListWebhooks(ctx context.Context, request ListWebhooksInternal) (*ListRegistryWebhooks, error) // Reject a transition request. // @@ -409,14 +409,14 @@ type ModelRegistryService interface { // Searches for specific model versions based on the supplied __filter__. // // Use SearchModelVersionsAll() to get all ModelVersion instances, which will iterate over every result page. - SearchModelVersions(ctx context.Context, request SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) + SearchModelVersions(ctx context.Context, request SearchModelVersionsInternal) (*SearchModelVersionsResponse, error) // Search models. // // Search for registered models based on the specified __filter__. // // Use SearchModelsAll() to get all Model instances, which will iterate over every result page. - SearchModels(ctx context.Context, request SearchModelsRequest) (*SearchModelsResponse, error) + SearchModels(ctx context.Context, request SearchModelsInternal) (*SearchModelsResponse, error) // Set a tag. // diff --git a/service/ml/model.go b/service/ml/model.go index f603769ba..81670fad9 100755 --- a/service/ml/model.go +++ b/service/ml/model.go @@ -827,8 +827,8 @@ type JobSpecWithoutSecret struct { WorkspaceUrl string `json:"workspace_url,omitempty"` } -// Get all artifacts -type ListArtifactsRequest struct { +// For internal use only +type ListArtifactsInternal struct { // Token indicating the page of artifact results to fetch PageToken string `json:"-" url:"page_token,omitempty"` // Filter artifacts matching this path (a relative path from the root @@ -841,6 +841,18 @@ type ListArtifactsRequest struct { RunUuid string `json:"-" url:"run_uuid,omitempty"` } +// Get all artifacts +type ListArtifactsRequest struct { + // Filter artifacts matching this path (a relative path from the root + // artifact directory). + Path string `json:"-" url:"path,omitempty"` + // ID of the run whose artifacts to list. Must be provided. + RunId string `json:"-" url:"run_id,omitempty"` + // [Deprecated, use run_id instead] ID of the run whose artifacts to list. + // This field will be removed in a future MLflow version. + RunUuid string `json:"-" url:"run_uuid,omitempty"` +} + type ListArtifactsResponse struct { // File location and metadata for artifacts. Files []FileInfo `json:"files,omitempty"` @@ -850,8 +862,8 @@ type ListArtifactsResponse struct { RootUri string `json:"root_uri,omitempty"` } -// List experiments -type ListExperimentsRequest struct { +// For internal use only +type ListExperimentsInternal struct { // Maximum number of experiments desired. If `max_results` is unspecified, // return all experiments. If `max_results` is too large, it'll be // automatically capped at 1000. Callers of this endpoint are encouraged to @@ -865,6 +877,19 @@ type ListExperimentsRequest struct { ViewType string `json:"-" url:"view_type,omitempty"` } +// List experiments +type ListExperimentsRequest struct { + // Maximum number of experiments desired. If `max_results` is unspecified, + // return all experiments. If `max_results` is too large, it'll be + // automatically capped at 1000. Callers of this endpoint are encouraged to + // pass max_results explicitly and leverage page_token to iterate through + // experiments. + MaxResults int `json:"-" url:"max_results,omitempty"` + // Qualifier for type of experiments to be returned. If unspecified, return + // only active experiments. + ViewType string `json:"-" url:"view_type,omitempty"` +} + type ListExperimentsResponse struct { // Paginated Experiments beginning with the first item on the requested // page. @@ -874,14 +899,20 @@ type ListExperimentsResponse struct { NextPageToken string `json:"next_page_token,omitempty"` } -// List models -type ListModelsRequest struct { +// For internal use only +type ListModelsInternal struct { // Maximum number of registered models desired. Max threshold is 1000. MaxResults int `json:"-" url:"max_results,omitempty"` // Pagination token to go to the next page based on a previous query. PageToken string `json:"-" url:"page_token,omitempty"` } +// List models +type ListModelsRequest struct { + // Maximum number of registered models desired. Max threshold is 1000. + MaxResults int `json:"-" url:"max_results,omitempty"` +} + type ListModelsResponse struct { // Pagination token to request next page of models for the same query. NextPageToken string `json:"next_page_token,omitempty"` @@ -909,8 +940,8 @@ type ListTransitionRequestsResponse struct { Requests []Activity `json:"requests,omitempty"` } -// List registry webhooks -type ListWebhooksRequest struct { +// For internal use only +type ListWebhooksInternal struct { // If `events` is specified, any webhook with one or more of the specified // trigger events is included in the output. If `events` is not specified, // webhooks of all event types are included in the output. @@ -922,6 +953,17 @@ type ListWebhooksRequest struct { PageToken string `json:"-" url:"page_token,omitempty"` } +// List registry webhooks +type ListWebhooksRequest struct { + // If `events` is specified, any webhook with one or more of the specified + // trigger events is included in the output. If `events` is not specified, + // webhooks of all event types are included in the output. + Events []RegistryWebhookEvent `json:"-" url:"events,omitempty"` + // If not specified, all webhooks associated with the specified events are + // listed, regardless of their associated model. + ModelName string `json:"-" url:"model_name,omitempty"` +} + type LogBatch struct { // Metrics to log. A single request can contain up to 1000 metrics, and up // to 1000 metrics, params, and tags in total. @@ -1541,6 +1583,23 @@ type RunTag struct { } type SearchExperiments struct { + // String representing a SQL filter condition (e.g. "name ILIKE + // 'my-experiment%'") + Filter string `json:"filter,omitempty"` + // Maximum number of experiments desired. Max threshold is 3000. + MaxResults int64 `json:"max_results,omitempty"` + // List of columns for ordering search results, which can include experiment + // name and last updated timestamp with an optional "DESC" or "ASC" + // annotation, where "ASC" is the default. Tiebreaks are done by experiment + // id DESC. + OrderBy []string `json:"order_by,omitempty"` + // Qualifier for type of experiments to be returned. If unspecified, return + // only active experiments. + ViewType SearchExperimentsViewType `json:"view_type,omitempty"` +} + +// For internal use only +type SearchExperimentsInternal struct { // String representing a SQL filter condition (e.g. "name ILIKE // 'my-experiment%'") Filter string `json:"filter,omitempty"` @@ -1597,8 +1656,8 @@ func (f *SearchExperimentsViewType) Type() string { return "SearchExperimentsViewType" } -// Searches model versions -type SearchModelVersionsRequest struct { +// For internal use only +type SearchModelVersionsInternal struct { // String filter condition, like "name='my-model-name'". Must be a single // boolean condition, with string values wrapped in single quotes. Filter string `json:"-" url:"filter,omitempty"` @@ -1613,6 +1672,20 @@ type SearchModelVersionsRequest struct { PageToken string `json:"-" url:"page_token,omitempty"` } +// Searches model versions +type SearchModelVersionsRequest struct { + // String filter condition, like "name='my-model-name'". Must be a single + // boolean condition, with string values wrapped in single quotes. + Filter string `json:"-" url:"filter,omitempty"` + // Maximum number of models desired. Max threshold is 10K. + MaxResults int `json:"-" url:"max_results,omitempty"` + // List of columns to be ordered by including model name, version, stage + // with an optional "DESC" or "ASC" annotation, where "ASC" is the default. + // Tiebreaks are done by latest stage transition timestamp, followed by name + // ASC, followed by version DESC. + OrderBy []string `json:"-" url:"order_by,omitempty"` +} + type SearchModelVersionsResponse struct { // Models that match the search criteria ModelVersions []ModelVersion `json:"model_versions,omitempty"` @@ -1621,8 +1694,8 @@ type SearchModelVersionsResponse struct { NextPageToken string `json:"next_page_token,omitempty"` } -// Search models -type SearchModelsRequest struct { +// For internal use only +type SearchModelsInternal struct { // String filter condition, like "name LIKE 'my-model-name'". Interpreted in // the backend automatically as "name LIKE '%my-model-name%'". Single // boolean condition, with string values wrapped in single quotes. @@ -1637,6 +1710,20 @@ type SearchModelsRequest struct { PageToken string `json:"-" url:"page_token,omitempty"` } +// Search models +type SearchModelsRequest struct { + // String filter condition, like "name LIKE 'my-model-name'". Interpreted in + // the backend automatically as "name LIKE '%my-model-name%'". Single + // boolean condition, with string values wrapped in single quotes. + Filter string `json:"-" url:"filter,omitempty"` + // Maximum number of models desired. Default is 100. Max threshold is 1000. + MaxResults int `json:"-" url:"max_results,omitempty"` + // List of columns for ordering search results, which can include model name + // and last updated timestamp with an optional "DESC" or "ASC" annotation, + // where "ASC" is the default. Tiebreaks are done by model name ASC. + OrderBy []string `json:"-" url:"order_by,omitempty"` +} + type SearchModelsResponse struct { // Pagination token to request the next page of models. NextPageToken string `json:"next_page_token,omitempty"` @@ -1645,6 +1732,37 @@ type SearchModelsResponse struct { } type SearchRuns struct { + // List of experiment IDs to search over. + ExperimentIds []string `json:"experiment_ids,omitempty"` + // A filter expression over params, metrics, and tags, that allows returning + // a subset of runs. The syntax is a subset of SQL that supports ANDing + // together binary operations between a param, metric, or tag and a + // constant. + // + // Example: `metrics.rmse < 1 and params.model_class = 'LogisticRegression'` + // + // You can select columns with special characters (hyphen, space, period, + // etc.) by using double quotes: `metrics."model class" = 'LinearRegression' + // and tags."user-name" = 'Tomas'` + // + // Supported operators are `=`, `!=`, `>`, `>=`, `<`, and `<=`. + Filter string `json:"filter,omitempty"` + // Maximum number of runs desired. Max threshold is 50000 + MaxResults int `json:"max_results,omitempty"` + // List of columns to be ordered by, including attributes, params, metrics, + // and tags with an optional "DESC" or "ASC" annotation, where "ASC" is the + // default. Example: ["params.input DESC", "metrics.alpha ASC", + // "metrics.rmse"] Tiebreaks are done by start_time DESC followed by run_id + // for runs with the same start time (and this is the default ordering + // criterion if order_by is not provided). + OrderBy []string `json:"order_by,omitempty"` + // Whether to display only active, only deleted, or all runs. Defaults to + // only active runs. + RunViewType SearchRunsRunViewType `json:"run_view_type,omitempty"` +} + +// For internal use only +type SearchRunsInternal struct { // List of experiment IDs to search over. ExperimentIds []string `json:"experiment_ids,omitempty"` // A filter expression over params, metrics, and tags, that allows returning diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 1df3a2ca0..eef5870c3 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -255,9 +255,15 @@ func (a *PipelinesAPI) GetUpdateByPipelineIdAndUpdateId(ctx context.Context, pip // This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPipelineEventsRequest) ([]PipelineEvent, error) { var results []PipelineEvent + listing := ListPipelineEventsInternal{ + Filter: request.Filter, + MaxResults: request.MaxResults, + OrderBy: request.OrderBy, + PipelineId: request.PipelineId, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.ListPipelineEvents(ctx, request) + response, err := a.impl.ListPipelineEvents(ctx, listing) if err != nil { return nil, err } @@ -267,7 +273,7 @@ func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPi for _, v := range response.Events { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } @@ -279,7 +285,7 @@ func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPi // // Retrieves events for a pipeline. func (a *PipelinesAPI) ListPipelineEventsByPipelineId(ctx context.Context, pipelineId string) (*ListPipelineEventsResponse, error) { - return a.impl.ListPipelineEvents(ctx, ListPipelineEventsRequest{ + return a.impl.ListPipelineEvents(ctx, ListPipelineEventsInternal{ PipelineId: pipelineId, }) } @@ -291,9 +297,14 @@ func (a *PipelinesAPI) ListPipelineEventsByPipelineId(ctx context.Context, pipel // This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelinesRequest) ([]PipelineStateInfo, error) { var results []PipelineStateInfo + listing := ListPipelinesInternal{ + Filter: request.Filter, + MaxResults: request.MaxResults, + OrderBy: request.OrderBy, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.ListPipelines(ctx, request) + response, err := a.impl.ListPipelines(ctx, listing) if err != nil { return nil, err } @@ -303,7 +314,7 @@ func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelin for _, v := range response.Statuses { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } diff --git a/service/pipelines/impl.go b/service/pipelines/impl.go index 88854ec98..afb2dd42a 100755 --- a/service/pipelines/impl.go +++ b/service/pipelines/impl.go @@ -56,14 +56,14 @@ func (a *pipelinesImpl) GetUpdate(ctx context.Context, request GetUpdateRequest) return &getUpdateResponse, err } -func (a *pipelinesImpl) ListPipelineEvents(ctx context.Context, request ListPipelineEventsRequest) (*ListPipelineEventsResponse, error) { +func (a *pipelinesImpl) ListPipelineEvents(ctx context.Context, request ListPipelineEventsInternal) (*ListPipelineEventsResponse, error) { var listPipelineEventsResponse ListPipelineEventsResponse path := fmt.Sprintf("/api/2.0/pipelines/%v/events", request.PipelineId) err := a.client.Do(ctx, http.MethodGet, path, request, &listPipelineEventsResponse) return &listPipelineEventsResponse, err } -func (a *pipelinesImpl) ListPipelines(ctx context.Context, request ListPipelinesRequest) (*ListPipelinesResponse, error) { +func (a *pipelinesImpl) ListPipelines(ctx context.Context, request ListPipelinesInternal) (*ListPipelinesResponse, error) { var listPipelinesResponse ListPipelinesResponse path := "/api/2.0/pipelines" err := a.client.Do(ctx, http.MethodGet, path, request, &listPipelinesResponse) diff --git a/service/pipelines/interface.go b/service/pipelines/interface.go index bb200c4c7..592b8362a 100755 --- a/service/pipelines/interface.go +++ b/service/pipelines/interface.go @@ -58,14 +58,14 @@ type PipelinesService interface { // Retrieves events for a pipeline. // // Use ListPipelineEventsAll() to get all PipelineEvent instances, which will iterate over every result page. - ListPipelineEvents(ctx context.Context, request ListPipelineEventsRequest) (*ListPipelineEventsResponse, error) + ListPipelineEvents(ctx context.Context, request ListPipelineEventsInternal) (*ListPipelineEventsResponse, error) // List pipelines. // // Lists pipelines defined in the Delta Live Tables system. // // Use ListPipelinesAll() to get all PipelineStateInfo instances, which will iterate over every result page. - ListPipelines(ctx context.Context, request ListPipelinesRequest) (*ListPipelinesResponse, error) + ListPipelines(ctx context.Context, request ListPipelinesInternal) (*ListPipelinesResponse, error) // List pipeline updates. // diff --git a/service/pipelines/model.go b/service/pipelines/model.go index 14c770685..f2db1b938 100755 --- a/service/pipelines/model.go +++ b/service/pipelines/model.go @@ -273,8 +273,8 @@ type GetUpdateResponse struct { Update *UpdateInfo `json:"update,omitempty"` } -// List pipeline events -type ListPipelineEventsRequest struct { +// For internal use only +type ListPipelineEventsInternal struct { // Criteria to select a subset of results, expressed using a SQL-like // syntax. The supported filters are: 1. level='INFO' (or WARN or ERROR) 2. // level in ('INFO', 'WARN') 3. id='[event-id]' 4. timestamp > 'TIMESTAMP' @@ -300,6 +300,29 @@ type ListPipelineEventsRequest struct { PipelineId string `json:"-" url:"-"` } +// List pipeline events +type ListPipelineEventsRequest struct { + // Criteria to select a subset of results, expressed using a SQL-like + // syntax. The supported filters are: 1. level='INFO' (or WARN or ERROR) 2. + // level in ('INFO', 'WARN') 3. id='[event-id]' 4. timestamp > 'TIMESTAMP' + // (or >=,<,<=,=) + // + // Composite expressions are supported, for example: level in ('ERROR', + // 'WARN') AND timestamp> '2021-07-22T06:37:33.083Z' + Filter string `json:"-" url:"filter,omitempty"` + // Max number of entries to return in a single page. The system may return + // fewer than max_results events in a response, even if there are more + // events available. + MaxResults int `json:"-" url:"max_results,omitempty"` + // A string indicating a sort order by timestamp for the results, for + // example, ["timestamp asc"]. The sort order can be ascending or + // descending. By default, events are returned in descending order by + // timestamp. + OrderBy []string `json:"-" url:"order_by,omitempty"` + + PipelineId string `json:"-" url:"-"` +} + type ListPipelineEventsResponse struct { // The list of events matching the request criteria. Events []PipelineEvent `json:"events,omitempty"` @@ -309,8 +332,8 @@ type ListPipelineEventsResponse struct { PrevPageToken string `json:"prev_page_token,omitempty"` } -// List pipelines -type ListPipelinesRequest struct { +// For internal use only +type ListPipelinesInternal struct { // Select a subset of results based on the specified criteria. The supported // filters are: // @@ -334,6 +357,29 @@ type ListPipelinesRequest struct { PageToken string `json:"-" url:"page_token,omitempty"` } +// List pipelines +type ListPipelinesRequest struct { + // Select a subset of results based on the specified criteria. The supported + // filters are: + // + // * `notebook=''` to select pipelines that reference the provided + // notebook path. * `name LIKE '[pattern]'` to select pipelines with a name + // that matches pattern. Wildcards are supported, for example: `name LIKE + // '%shopping%'` + // + // Composite filters are not supported. This field is optional. + Filter string `json:"-" url:"filter,omitempty"` + // The maximum number of entries to return in a single page. The system may + // return fewer than max_results events in a response, even if there are + // more events available. This field is optional. The default value is 25. + // The maximum value is 100. An error is returned if the value of + // max_results is greater than 100. + MaxResults int `json:"-" url:"max_results,omitempty"` + // A list of strings specifying the order of results. Supported order_by + // fields are id and name. The default is id asc. This field is optional. + OrderBy []string `json:"-" url:"order_by,omitempty"` +} + type ListPipelinesResponse struct { // If present, a token to fetch the next page of events. NextPageToken string `json:"next_page_token,omitempty"` diff --git a/service/sql/api.go b/service/sql/api.go index 9a3def1da..6ab4805b5 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -236,13 +236,17 @@ func (a *DashboardsAPI) GetByDashboardId(ctx context.Context, dashboardId string // This method is generated by Databricks SDK Code Generator. func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { var results []Dashboard + listing := ListDashboardsInternal{ + Order: request.Order, + Q: request.Q, + } var totalCount int = 0 ctx = useragent.InContext(ctx, "sdk-feature", "pagination") // deduplicate items that may have been added during iteration seen := map[string]bool{} - request.Page = 1 // start iterating from the first page + listing.Page = 1 // start iterating from the first page for { - response, err := a.impl.List(ctx, request) + response, err := a.impl.List(ctx, listing) if err != nil { return nil, err } @@ -260,8 +264,8 @@ func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsReque } count := int(len(response.Results)) totalCount += count - request.Page++ - limit := request.PageSize + listing.Page++ + limit := listing.PageSize if limit > 0 && totalCount >= limit { break } @@ -592,13 +596,17 @@ func (a *QueriesAPI) GetByQueryId(ctx context.Context, queryId string) (*Query, // This method is generated by Databricks SDK Code Generator. func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { var results []Query + listing := ListQueriesInternal{ + Order: request.Order, + Q: request.Q, + } var totalCount int = 0 ctx = useragent.InContext(ctx, "sdk-feature", "pagination") // deduplicate items that may have been added during iteration seen := map[string]bool{} - request.Page = 1 // start iterating from the first page + listing.Page = 1 // start iterating from the first page for { - response, err := a.impl.List(ctx, request) + response, err := a.impl.List(ctx, listing) if err != nil { return nil, err } @@ -616,8 +624,8 @@ func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([ } count := int(len(response.Results)) totalCount += count - request.Page++ - limit := request.PageSize + listing.Page++ + limit := listing.PageSize if limit > 0 && totalCount >= limit { break } @@ -731,9 +739,14 @@ func (a *QueryHistoryAPI) Impl() QueryHistoryService { // This method is generated by Databricks SDK Code Generator. func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) { var results []QueryInfo + listing := ListQueryHistoryInternal{ + FilterBy: request.FilterBy, + IncludeMetrics: request.IncludeMetrics, + MaxResults: request.MaxResults, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.List(ctx, request) + response, err := a.impl.List(ctx, listing) if err != nil { return nil, err } @@ -743,7 +756,7 @@ func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryR for _, v := range response.Res { results = append(results, v) } - request.PageToken = response.NextPageToken + listing.PageToken = response.NextPageToken if response.NextPageToken == "" { break } diff --git a/service/sql/impl.go b/service/sql/impl.go index c042af794..7e7ec808b 100755 --- a/service/sql/impl.go +++ b/service/sql/impl.go @@ -73,7 +73,7 @@ func (a *dashboardsImpl) Get(ctx context.Context, request GetDashboardRequest) ( return &dashboard, err } -func (a *dashboardsImpl) List(ctx context.Context, request ListDashboardsRequest) (*ListResponse, error) { +func (a *dashboardsImpl) List(ctx context.Context, request ListDashboardsInternal) (*ListResponse, error) { var listResponse ListResponse path := "/api/2.0/preview/sql/dashboards" err := a.client.Do(ctx, http.MethodGet, path, request, &listResponse) @@ -149,7 +149,7 @@ func (a *queriesImpl) Get(ctx context.Context, request GetQueryRequest) (*Query, return &query, err } -func (a *queriesImpl) List(ctx context.Context, request ListQueriesRequest) (*QueryList, error) { +func (a *queriesImpl) List(ctx context.Context, request ListQueriesInternal) (*QueryList, error) { var queryList QueryList path := "/api/2.0/preview/sql/queries" err := a.client.Do(ctx, http.MethodGet, path, request, &queryList) @@ -174,7 +174,7 @@ type queryHistoryImpl struct { client *client.DatabricksClient } -func (a *queryHistoryImpl) List(ctx context.Context, request ListQueryHistoryRequest) (*ListQueriesResponse, error) { +func (a *queryHistoryImpl) List(ctx context.Context, request ListQueryHistoryInternal) (*ListQueriesResponse, error) { var listQueriesResponse ListQueriesResponse path := "/api/2.0/sql/history/queries" err := a.client.Do(ctx, http.MethodGet, path, request, &listQueriesResponse) diff --git a/service/sql/interface.go b/service/sql/interface.go index 6e2dee0c8..a0d922ab9 100755 --- a/service/sql/interface.go +++ b/service/sql/interface.go @@ -71,7 +71,7 @@ type DashboardsService interface { // Fetch a paginated list of dashboard objects. // // Use ListAll() to get all Dashboard instances, which will iterate over every result page. - List(ctx context.Context, request ListDashboardsRequest) (*ListResponse, error) + List(ctx context.Context, request ListDashboardsInternal) (*ListResponse, error) // Restore a dashboard. // @@ -173,7 +173,7 @@ type QueriesService interface { // term. // // Use ListAll() to get all Query instances, which will iterate over every result page. - List(ctx context.Context, request ListQueriesRequest) (*QueryList, error) + List(ctx context.Context, request ListQueriesInternal) (*QueryList, error) // Restore a query. // @@ -200,7 +200,7 @@ type QueryHistoryService interface { // You can filter by user ID, warehouse ID, status, and time range. // // Use ListAll() to get all QueryInfo instances, which will iterate over every result page. - List(ctx context.Context, request ListQueryHistoryRequest) (*ListQueriesResponse, error) + List(ctx context.Context, request ListQueryHistoryInternal) (*ListQueriesResponse, error) } // The SQL Statement Execution API manages the execution of arbitrary SQL diff --git a/service/sql/model.go b/service/sql/model.go index 1759409a8..a3499ba84 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -159,6 +159,7 @@ type ChannelInfo struct { Name ChannelName `json:"name,omitempty"` } +// Name of the channel type ChannelName string const ChannelNameChannelNameCurrent ChannelName = `CHANNEL_NAME_CURRENT` @@ -1285,8 +1286,8 @@ func (f *GetWorkspaceWarehouseConfigResponseSecurityPolicy) Type() string { return "GetWorkspaceWarehouseConfigResponseSecurityPolicy" } -// Get dashboard objects -type ListDashboardsRequest struct { +// For internal use only +type ListDashboardsInternal struct { // Name of dashboard attribute to order by. Order ListOrder `json:"-" url:"order,omitempty"` // Page number to retrieve. @@ -1297,6 +1298,14 @@ type ListDashboardsRequest struct { Q string `json:"-" url:"q,omitempty"` } +// Get dashboard objects +type ListDashboardsRequest struct { + // Name of dashboard attribute to order by. + Order ListOrder `json:"-" url:"order,omitempty"` + // Full text search term. + Q string `json:"-" url:"q,omitempty"` +} + type ListOrder string const ListOrderCreatedAt ListOrder = `created_at` @@ -1324,8 +1333,8 @@ func (f *ListOrder) Type() string { return "ListOrder" } -// Get a list of queries -type ListQueriesRequest struct { +// For internal use only +type ListQueriesInternal struct { // Name of query attribute to order by. Default sort order is ascending. // Append a dash (`-`) to order descending instead. // @@ -1349,6 +1358,27 @@ type ListQueriesRequest struct { Q string `json:"-" url:"q,omitempty"` } +// Get a list of queries +type ListQueriesRequest struct { + // Name of query attribute to order by. Default sort order is ascending. + // Append a dash (`-`) to order descending instead. + // + // - `name`: The name of the query. + // + // - `created_at`: The timestamp the query was created. + // + // - `runtime`: The time it took to run this query. This is blank for + // parameterized queries. A blank value is treated as the highest value for + // sorting. + // + // - `executed_at`: The timestamp when the query was last run. + // + // - `created_by`: The user name of the user that created the query. + Order string `json:"-" url:"order,omitempty"` + // Full text search term + Q string `json:"-" url:"q,omitempty"` +} + type ListQueriesResponse struct { // Whether there is another page of results. HasNextPage bool `json:"has_next_page,omitempty"` @@ -1358,8 +1388,8 @@ type ListQueriesResponse struct { Res []QueryInfo `json:"res,omitempty"` } -// List Queries -type ListQueryHistoryRequest struct { +// For internal use only +type ListQueryHistoryInternal 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. @@ -1370,6 +1400,16 @@ type ListQueryHistoryRequest struct { PageToken string `json:"-" url:"page_token,omitempty"` } +// List Queries +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. + MaxResults int `json:"-" url:"max_results,omitempty"` +} + type ListResponse struct { // The total number of dashboards. Count int `json:"count,omitempty"` diff --git a/service/workspace/api.go b/service/workspace/api.go index 36c527bbc..ba10bb95c 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -278,9 +278,12 @@ func (a *ReposAPI) GetRepoPermissionsByRepoId(ctx context.Context, repoId string // This method is generated by Databricks SDK Code Generator. func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error) { var results []RepoInfo + listing := ListReposInternal{ + PathPrefix: request.PathPrefix, + } ctx = useragent.InContext(ctx, "sdk-feature", "pagination") for { - response, err := a.impl.List(ctx, request) + response, err := a.impl.List(ctx, listing) if err != nil { return nil, err } @@ -290,7 +293,7 @@ func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]Rep for _, v := range response.Repos { results = append(results, v) } - request.NextPageToken = response.NextPageToken + listing.NextPageToken = response.NextPageToken if response.NextPageToken == "" { break } diff --git a/service/workspace/impl.go b/service/workspace/impl.go index 15ad0a0c2..91125d37d 100755 --- a/service/workspace/impl.go +++ b/service/workspace/impl.go @@ -87,7 +87,7 @@ func (a *reposImpl) GetRepoPermissions(ctx context.Context, request GetRepoPermi return &repoPermissions, err } -func (a *reposImpl) List(ctx context.Context, request ListReposRequest) (*ListReposResponse, error) { +func (a *reposImpl) List(ctx context.Context, request ListReposInternal) (*ListReposResponse, error) { var listReposResponse ListReposResponse path := "/api/2.0/repos" err := a.client.Do(ctx, http.MethodGet, path, request, &listReposResponse) diff --git a/service/workspace/interface.go b/service/workspace/interface.go index 512140c28..13776ad53 100755 --- a/service/workspace/interface.go +++ b/service/workspace/interface.go @@ -92,7 +92,7 @@ type ReposService interface { // are paginated with each page containing twenty repos. // // Use ListAll() to get all RepoInfo instances, which will iterate over every result page. - List(ctx context.Context, request ListReposRequest) (*ListReposResponse, error) + List(ctx context.Context, request ListReposInternal) (*ListReposResponse, error) // Set repo permissions. // diff --git a/service/workspace/model.go b/service/workspace/model.go index 5f55eacf8..e29c8663a 100755 --- a/service/workspace/model.go +++ b/service/workspace/model.go @@ -405,8 +405,8 @@ type ListAclsResponse struct { Items []AclItem `json:"items,omitempty"` } -// Get repos -type ListReposRequest struct { +// For internal use only +type ListReposInternal struct { // Token used to get the next page of results. If not specified, returns the // first page of results as well as a next page token if there are more // results. @@ -415,6 +415,12 @@ type ListReposRequest struct { PathPrefix string `json:"-" url:"path_prefix,omitempty"` } +// Get repos +type ListReposRequest struct { + // Filters repos that have paths starting with the given path prefix. + PathPrefix string `json:"-" url:"path_prefix,omitempty"` +} + type ListReposResponse struct { // Token that can be specified as a query parameter to the GET /repos // endpoint to retrieve the next page of results.