From 59f335ab9ec3c62a9c888b23fe5b41b51905199d Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 19 Oct 2023 11:52:26 +0200 Subject: [PATCH 01/24] small formatting cleanup --- .codegen/api.go.tmpl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 13d7e80c5..7f7463c9a 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -163,7 +163,8 @@ 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}}) ([]{{ template "type" .Pagination.Entity }}, error) { - {{if .Pagination.MultiRequest}}var results []{{.Pagination.Entity.PascalName}} + {{if .Pagination.MultiRequest -}} + var results []{{.Pagination.Entity.PascalName}} {{ if .Pagination.Limit -}} var totalCount {{template "type" .Pagination.Limit.Entity}} = 0 {{ end -}} @@ -221,11 +222,16 @@ func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Reque } {{- end -}} } - return results, nil{{else if .Pagination.Results}}response, err := a.impl.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) + return results, nil + {{- else if .Pagination.Results -}} + response, err := a.impl.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) if err != nil { return nil, err } - return response.{{.Pagination.Results.PascalName}}, nil{{else}}return a.impl.{{.PascalName}}(ctx, request){{end}} + return response.{{.Pagination.Results.PascalName}}, nil + {{- else -}} + return a.impl.{{.PascalName}}(ctx, request) + {{- end}} } {{end}}{{if .NamedIdMap}} // {{.NamedIdMap.PascalName}} calls [{{.Service.Name}}API.{{.PascalName}}{{if not .NamedIdMap.Direct}}All{{end -}}] and creates a map of results with [{{.NamedIdMap.Entity.PascalName}}]{{ template "field-path" .NamedIdMap.NamePath }} as key and [{{.NamedIdMap.Entity.PascalName}}]{{ template "field-path" .NamedIdMap.IdPath}} as value. From ea63120b350fcd1ffc1e8792b0e187e40b7b90c6 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 19 Oct 2023 15:07:52 +0200 Subject: [PATCH 02/24] Work --- .codegen/api.go.tmpl | 29 +++ listing/listing.go | 73 ++++++++ service/billing/api.go | 31 +++ service/catalog/api.go | 238 ++++++++++++++++++++++++ service/compute/api.go | 127 +++++++++++++ service/files/api.go | 16 ++ service/iam/api.go | 106 +++++++++++ service/iam/model.go | 4 +- service/jobs/api.go | 37 ++++ service/jobs/jobs_usage_test.go | 58 ++++++ service/ml/api.go | 193 +++++++++++++++++++ service/ml/model_registry_usage_test.go | 4 +- service/oauth2/api.go | 64 +++++++ service/pipelines/api.go | 37 ++++ service/serving/api.go | 16 ++ service/settings/api.go | 61 ++++++ service/sharing/api.go | 79 ++++++++ service/sql/api.go | 70 +++++++ service/sql/model.go | 1 + service/workspace/api.go | 94 ++++++++++ 20 files changed, 1334 insertions(+), 4 deletions(-) create mode 100644 listing/listing.go diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 7f7463c9a..b600668f9 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -9,6 +9,7 @@ import ( "time" "github.com/databricks/databricks-sdk-go/retries" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/useragent" ) {{range .Services}} @@ -162,6 +163,34 @@ func (a *{{.Service.Name}}API) {{.PascalName}}AndWait(ctx context.Context{{if .R {{.Comment "// " 80}} // // This method is generated by Databricks SDK Code Generator. +func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) *listing.Iterator[{{if .Request}}{{.Request.PascalName}}{{else}}struct{}{{end}}, *{{ .Response.PascalName }}, {{template "type" .Pagination.Entity}}] { + getNextPage := func(ctx context.Context, req {{if .Request}}{{.Request.PascalName}}{{else}}struct{}{{end}}) (*{{ .Response.PascalName }}, error) { + return a.impl.{{.PascalName}}(ctx{{if .Request}}, req{{end}}) + } + getItems := func(resp *{{ .Response.PascalName }}) []{{ template "type" .Pagination.Entity }} { + return {{if .Pagination.Results}}resp.{{.Pagination.Results.PascalName}}{{else}}resp{{end}} + } + {{if .Pagination.MultiRequest -}} + getNextReq := func(resp *{{ .Response.PascalName }}) {{.Request.PascalName}} { + {{if .Pagination.Token -}} + request.{{.Pagination.Token.PollField.PascalName}} = resp.{{.Pagination.Token.Bind.PascalName}} + {{- else if eq .Pagination.Increment 1 -}} + request.{{.Pagination.Offset.PascalName}} = resp.{{.Pagination.Offset.PascalName}} + 1 + {{- else if eq .Path "/api/2.0/clusters/events" -}} + request = *resp.NextPage + {{- else -}} + request.{{.Pagination.Offset.PascalName}} = resp.{{.Pagination.Offset.PascalName}} + {{template "type" .Pagination.Offset.Entity}}(len(resp.{{.Pagination.Results.PascalName}})) + {{- end}} + return request + } + {{- end}} + return listing.NewIterator( + {{if .Request}}request{{else}}struct{}{}{{end}}, + getNextPage, + getItems, + {{if .Pagination.MultiRequest}}getNextReq{{else}}nil{{end}}) +} + func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{ template "type" .Pagination.Entity }}, error) { {{if .Pagination.MultiRequest -}} var results []{{.Pagination.Entity.PascalName}} diff --git a/listing/listing.go b/listing/listing.go new file mode 100644 index 000000000..be74b841d --- /dev/null +++ b/listing/listing.go @@ -0,0 +1,73 @@ +package listing + +import ( + "context" + "errors" +) + +// Use struct{} for Req to indicate one-shot iterator. +type Iterator[Req, Resp, T any] struct { + nextReq Req + getNextPage func(context.Context, Req) (Resp, error) + getItems func(Resp) []T + getNextReq func(Resp) Req + currentPage []T + currentPageIdx int + isExhausted bool +} + +var ErrNoMoreItems = errors.New("no more items") + +func NewIterator[Req, Resp, T any]( + nextReq Req, + getNextPage func(context.Context, Req) (Resp, error), + getItems func(Resp) []T, + getNextReq func(Resp) Req, +) *Iterator[Req, Resp, T] { + return &Iterator[Req, Resp, T]{ + nextReq: nextReq, + getNextPage: getNextPage, + getItems: getItems, + getNextReq: getNextReq, + } +} + +func (i *Iterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) (bool, error) { + if i.currentPageIdx < len(i.currentPage) { + return true, nil + } + + if i.isExhausted { + return false, ErrNoMoreItems + } + resp, err := i.getNextPage(ctx, i.nextReq) + if err != nil { + return false, err + } + items := i.getItems(resp) + i.currentPage = items + i.currentPageIdx = 0 + i.nextReq = i.getNextReq(resp) + if !i.isExhausted && len(items) == 0 { + i.isExhausted = true + } + return !i.isExhausted, err +} + +func (i *Iterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { + var t T + ok, err := i.loadNextPageIfNeeded(ctx) + if err != nil { + return t, err + } + if !ok { + return t, ErrNoMoreItems + } + item := i.currentPage[i.currentPageIdx] + i.currentPageIdx++ + return item, nil +} + +func (i *Iterator[Req, Resp, T]) HasNext(ctx context.Context) (bool, error) { + return i.loadNextPageIfNeeded(ctx) +} diff --git a/service/billing/api.go b/service/billing/api.go index 22ad7f146..4713e3a26 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -130,6 +131,21 @@ func (a *BudgetsAPI) GetByBudgetId(ctx context.Context, budgetId string) (*Wrapp // for each day that the budget is configured to include. // // This method is generated by Databricks SDK Code Generator. +func (a *BudgetsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *BudgetList, BudgetWithStatus] { + getNextPage := func(ctx context.Context, req struct{}) (*BudgetList, error) { + return a.impl.List(ctx) + } + getItems := func(resp *BudgetList) []BudgetWithStatus { + return resp.Budgets + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { response, err := a.impl.List(ctx) if err != nil { @@ -341,6 +357,21 @@ func (a *LogDeliveryAPI) GetByLogDeliveryConfigurationId(ctx context.Context, lo // specified by ID. // // This method is generated by Databricks SDK Code Generator. +func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryRequest) *listing.Iterator[ListLogDeliveryRequest, *WrappedLogDeliveryConfigurations, LogDeliveryConfiguration] { + getNextPage := func(ctx context.Context, req ListLogDeliveryRequest) (*WrappedLogDeliveryConfigurations, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *WrappedLogDeliveryConfigurations) []LogDeliveryConfiguration { + return resp.LogDeliveryConfigurations + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *LogDeliveryAPI) ListAll(ctx context.Context, request ListLogDeliveryRequest) ([]LogDeliveryConfiguration, error) { response, err := a.impl.List(ctx, request) if err != nil { diff --git a/service/catalog/api.go b/service/catalog/api.go index c4c2799cb..2da3c1676 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -92,6 +93,21 @@ func (a *AccountMetastoreAssignmentsAPI) GetByWorkspaceId(ctx context.Context, w // metastore. // // This method is generated by Databricks SDK Code Generator. +func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) *listing.Iterator[ListAccountMetastoreAssignmentsRequest, *ListAccountMetastoreAssignmentsResponse, int64] { + getNextPage := func(ctx context.Context, req ListAccountMetastoreAssignmentsRequest) (*ListAccountMetastoreAssignmentsResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListAccountMetastoreAssignmentsResponse) []int64 { + return resp.WorkspaceIds + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *AccountMetastoreAssignmentsAPI) ListAll(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) ([]int64, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -190,6 +206,21 @@ func (a *AccountMetastoresAPI) GetByMetastoreId(ctx context.Context, metastoreId // Gets all Unity Catalog metastores associated with an account specified by ID. // // This method is generated by Databricks SDK Code Generator. +func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListMetastoresResponse, MetastoreInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListMetastoresResponse) []MetastoreInfo { + return resp.Metastores + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *AccountMetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { response, err := a.impl.List(ctx) if err != nil { @@ -511,6 +542,21 @@ func (a *CatalogsAPI) GetByName(ctx context.Context, name string) (*CatalogInfo, // the array. // // This method is generated by Databricks SDK Code Generator. +func (a *CatalogsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListCatalogsResponse, CatalogInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListCatalogsResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListCatalogsResponse) []CatalogInfo { + return resp.Catalogs + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *CatalogsAPI) ListAll(ctx context.Context) ([]CatalogInfo, error) { response, err := a.impl.List(ctx) if err != nil { @@ -613,6 +659,21 @@ func (a *ConnectionsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Con // List all connections. // // This method is generated by Databricks SDK Code Generator. +func (a *ConnectionsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListConnectionsResponse, ConnectionInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListConnectionsResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListConnectionsResponse) []ConnectionInfo { + return resp.Connections + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *ConnectionsAPI) ListAll(ctx context.Context) ([]ConnectionInfo, error) { response, err := a.impl.List(ctx) if err != nil { @@ -776,6 +837,21 @@ func (a *ExternalLocationsAPI) GetByName(ctx context.Context, name string) (*Ext // array. // // This method is generated by Databricks SDK Code Generator. +func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListExternalLocationsResponse, ExternalLocationInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListExternalLocationsResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListExternalLocationsResponse) []ExternalLocationInfo { + return resp.ExternalLocations + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *ExternalLocationsAPI) ListAll(ctx context.Context) ([]ExternalLocationInfo, error) { response, err := a.impl.List(ctx) if err != nil { @@ -903,6 +979,21 @@ func (a *FunctionsAPI) GetByName(ctx context.Context, name string) (*FunctionInf // the array. // // This method is generated by Databricks SDK Code Generator. +func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) *listing.Iterator[ListFunctionsRequest, *ListFunctionsResponse, FunctionInfo] { + getNextPage := func(ctx context.Context, req ListFunctionsRequest) (*ListFunctionsResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListFunctionsResponse) []FunctionInfo { + return resp.Functions + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *FunctionsAPI) ListAll(ctx context.Context, request ListFunctionsRequest) ([]FunctionInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -1139,6 +1230,21 @@ func (a *MetastoresAPI) GetById(ctx context.Context, id string) (*MetastoreInfo, // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. +func (a *MetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListMetastoresResponse, MetastoreInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListMetastoresResponse) []MetastoreInfo { + return resp.Metastores + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *MetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { response, err := a.impl.List(ctx) if err != nil { @@ -1375,6 +1481,24 @@ func (a *ModelVersionsAPI) GetByAliasByFullNameAndAlias(ctx context.Context, ful // There is no guarantee of a specific ordering of the elements in the response. // // This method is generated by Databricks SDK Code Generator. +func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRequest) *listing.Iterator[ListModelVersionsRequest, *ListModelVersionsResponse, ModelVersionInfo] { + getNextPage := func(ctx context.Context, req ListModelVersionsRequest) (*ListModelVersionsResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListModelVersionsResponse) []ModelVersionInfo { + return resp.ModelVersions + } + getNextReq := func(resp *ListModelVersionsResponse) ListModelVersionsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersionsRequest) ([]ModelVersionInfo, error) { var results []ModelVersionInfo var totalCount int = 0 @@ -1608,6 +1732,24 @@ func (a *RegisteredModelsAPI) GetByFullName(ctx context.Context, fullName string // There is no guarantee of a specific ordering of the elements in the response. // // This method is generated by Databricks SDK Code Generator. +func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) *listing.Iterator[ListRegisteredModelsRequest, *ListRegisteredModelsResponse, RegisteredModelInfo] { + getNextPage := func(ctx context.Context, req ListRegisteredModelsRequest) (*ListRegisteredModelsResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListRegisteredModelsResponse) []RegisteredModelInfo { + return resp.RegisteredModels + } + getNextReq := func(resp *ListRegisteredModelsResponse) ListRegisteredModelsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegisteredModelsRequest) ([]RegisteredModelInfo, error) { var results []RegisteredModelInfo var totalCount int = 0 @@ -1804,6 +1946,21 @@ func (a *SchemasAPI) GetByFullName(ctx context.Context, fullName string) (*Schem // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. +func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *listing.Iterator[ListSchemasRequest, *ListSchemasResponse, SchemaInfo] { + getNextPage := func(ctx context.Context, req ListSchemasRequest) (*ListSchemasResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListSchemasResponse) []SchemaInfo { + return resp.Schemas + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *SchemasAPI) ListAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -1969,6 +2126,21 @@ func (a *StorageCredentialsAPI) GetByName(ctx context.Context, name string) (*St // of the elements in the array. // // This method is generated by Databricks SDK Code Generator. +func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListStorageCredentialsResponse, StorageCredentialInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListStorageCredentialsResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListStorageCredentialsResponse) []StorageCredentialInfo { + return resp.StorageCredentials + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *StorageCredentialsAPI) ListAll(ctx context.Context) ([]StorageCredentialInfo, error) { response, err := a.impl.List(ctx) if err != nil { @@ -2089,6 +2261,21 @@ func (a *SystemSchemasAPI) Enable(ctx context.Context, request EnableRequest) er // account admin or a metastore admin. // // This method is generated by Databricks SDK Code Generator. +func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRequest) *listing.Iterator[ListSystemSchemasRequest, *ListSystemSchemasResponse, SystemSchemaInfo] { + getNextPage := func(ctx context.Context, req ListSystemSchemasRequest) (*ListSystemSchemasResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListSystemSchemasResponse) []SystemSchemaInfo { + return resp.Schemas + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *SystemSchemasAPI) ListAll(ctx context.Context, request ListSystemSchemasRequest) ([]SystemSchemaInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -2288,6 +2475,24 @@ func (a *TablesAPI) GetByFullName(ctx context.Context, fullName string) (*TableI // guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. +func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listing.Iterator[ListTablesRequest, *ListTablesResponse, TableInfo] { + getNextPage := func(ctx context.Context, req ListTablesRequest) (*ListTablesResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListTablesResponse) []TableInfo { + return resp.Tables + } + getNextReq := func(resp *ListTablesResponse) ListTablesRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { var results []TableInfo var totalCount int = 0 @@ -2385,6 +2590,24 @@ func (a *TablesAPI) GetByName(ctx context.Context, name string) (*TableInfo, err // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. +func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequest) *listing.Iterator[ListSummariesRequest, *ListTableSummariesResponse, TableSummary] { + getNextPage := func(ctx context.Context, req ListSummariesRequest) (*ListTableSummariesResponse, error) { + return a.impl.ListSummaries(ctx, req) + } + getItems := func(resp *ListTableSummariesResponse) []TableSummary { + return resp.Tables + } + getNextReq := func(resp *ListTableSummariesResponse) ListSummariesRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesRequest) ([]TableSummary, error) { var results []TableSummary var totalCount int = 0 @@ -2524,6 +2747,21 @@ func (a *VolumesAPI) DeleteByFullNameArg(ctx context.Context, fullNameArg string // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. +func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *listing.Iterator[ListVolumesRequest, *ListVolumesResponseContent, VolumeInfo] { + getNextPage := func(ctx context.Context, req ListVolumesRequest) (*ListVolumesResponseContent, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListVolumesResponseContent) []VolumeInfo { + return resp.Volumes + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *VolumesAPI) ListAll(ctx context.Context, request ListVolumesRequest) ([]VolumeInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { diff --git a/service/compute/api.go b/service/compute/api.go index 0c814bbbd..423e3c55f 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -9,6 +9,7 @@ import ( "time" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/retries" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -153,6 +154,21 @@ func (a *ClusterPoliciesAPI) GetPermissionsByClusterPolicyId(ctx context.Context // Returns a list of policies accessible by the requesting user. // // This method is generated by Databricks SDK Code Generator. +func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPoliciesRequest) *listing.Iterator[ListClusterPoliciesRequest, *ListPoliciesResponse, Policy] { + getNextPage := func(ctx context.Context, req ListClusterPoliciesRequest) (*ListPoliciesResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListPoliciesResponse) []Policy { + return resp.Policies + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request ListClusterPoliciesRequest) ([]Policy, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -583,6 +599,24 @@ func (a *ClustersAPI) EditAndWait(ctx context.Context, editCluster EditCluster, // nparameters necessary to request the next page of events. // // This method is generated by Databricks SDK Code Generator. +func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.Iterator[GetEvents, *GetEventsResponse, ClusterEvent] { + getNextPage := func(ctx context.Context, req GetEvents) (*GetEventsResponse, error) { + return a.impl.Events(ctx, req) + } + getItems := func(resp *GetEventsResponse) []ClusterEvent { + return resp.Events + } + getNextReq := func(resp *GetEventsResponse) GetEvents { + request = *resp.NextPage + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) { var results []ClusterEvent var totalCount int64 = 0 @@ -677,6 +711,21 @@ func (a *ClustersAPI) GetPermissionsByClusterId(ctx context.Context, clusterId s // terminated job clusters. // // This method is generated by Databricks SDK Code Generator. +func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *listing.Iterator[ListClustersRequest, *ListClustersResponse, ClusterDetails] { + getNextPage := func(ctx context.Context, req ListClustersRequest) (*ListClustersResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListClustersResponse) []ClusterDetails { + return resp.Clusters + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) ([]ClusterDetails, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -1491,6 +1540,21 @@ func (a *GlobalInitScriptsAPI) GetByScriptId(ctx context.Context, scriptId strin // script](#operation/get-script) operation. // // This method is generated by Databricks SDK Code Generator. +func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListGlobalInitScriptsResponse, GlobalInitScriptDetails] { + getNextPage := func(ctx context.Context, req struct{}) (*ListGlobalInitScriptsResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListGlobalInitScriptsResponse) []GlobalInitScriptDetails { + return resp.Scripts + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *GlobalInitScriptsAPI) ListAll(ctx context.Context) ([]GlobalInitScriptDetails, error) { response, err := a.impl.List(ctx) if err != nil { @@ -1691,6 +1755,21 @@ func (a *InstancePoolsAPI) GetPermissionsByInstancePoolId(ctx context.Context, i // Gets a list of instance pools with their statistics. // // This method is generated by Databricks SDK Code Generator. +func (a *InstancePoolsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListInstancePools, InstancePoolAndStats] { + getNextPage := func(ctx context.Context, req struct{}) (*ListInstancePools, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListInstancePools) []InstancePoolAndStats { + return resp.InstancePools + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, error) { response, err := a.impl.List(ctx) if err != nil { @@ -1836,6 +1915,21 @@ func (a *InstanceProfilesAPI) Edit(ctx context.Context, request InstanceProfile) // This API is available to all users. // // This method is generated by Databricks SDK Code Generator. +func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListInstanceProfilesResponse, InstanceProfile] { + getNextPage := func(ctx context.Context, req struct{}) (*ListInstanceProfilesResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListInstanceProfilesResponse) []InstanceProfile { + return resp.InstanceProfiles + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *InstanceProfilesAPI) ListAll(ctx context.Context) ([]InstanceProfile, error) { response, err := a.impl.List(ctx) if err != nil { @@ -1941,6 +2035,21 @@ func (a *LibrariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterL // guarantee. // // This method is generated by Databricks SDK Code Generator. +func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) *listing.Iterator[ClusterStatusRequest, *ClusterLibraryStatuses, LibraryFullStatus] { + getNextPage := func(ctx context.Context, req ClusterStatusRequest) (*ClusterLibraryStatuses, error) { + return a.impl.ClusterStatus(ctx, req) + } + getItems := func(resp *ClusterLibraryStatuses) []LibraryFullStatus { + return resp.LibraryStatuses + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *LibrariesAPI) ClusterStatusAll(ctx context.Context, request ClusterStatusRequest) ([]LibraryFullStatus, error) { response, err := a.impl.ClusterStatus(ctx, request) if err != nil { @@ -2049,6 +2158,24 @@ func (a *PolicyFamiliesAPI) GetByPolicyFamilyId(ctx context.Context, policyFamil // Retrieve a list of policy families. This API is paginated. // // This method is generated by Databricks SDK Code Generator. +func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamiliesRequest) *listing.Iterator[ListPolicyFamiliesRequest, *ListPolicyFamiliesResponse, PolicyFamily] { + getNextPage := func(ctx context.Context, req ListPolicyFamiliesRequest) (*ListPolicyFamiliesResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListPolicyFamiliesResponse) []PolicyFamily { + return resp.PolicyFamilies + } + getNextReq := func(resp *ListPolicyFamiliesResponse) ListPolicyFamiliesRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamiliesRequest) ([]PolicyFamily, error) { var results []PolicyFamily var totalCount int64 = 0 diff --git a/service/files/api.go b/service/files/api.go index dd8eb2c3b..837e959f2 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -7,6 +7,7 @@ import ( "context" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" ) func NewDbfs(client *client.DatabricksClient) *DbfsAPI { @@ -140,6 +141,21 @@ func (a *DbfsAPI) GetStatusByPath(ctx context.Context, path string) (*FileInfo, // which provides the same functionality without timing out. // // This method is generated by Databricks SDK Code Generator. +func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.Iterator[ListDbfsRequest, *ListStatusResponse, FileInfo] { + getNextPage := func(ctx context.Context, req ListDbfsRequest) (*ListStatusResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListStatusResponse) []FileInfo { + return resp.Files + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *DbfsAPI) ListAll(ctx context.Context, request ListDbfsRequest) ([]FileInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { diff --git a/service/iam/api.go b/service/iam/api.go index 45b59de49..c811b4e16 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -202,6 +203,21 @@ func (a *AccountGroupsAPI) GetById(ctx context.Context, id string) (*Group, erro // Gets all details of the groups associated with the Databricks account. // // This method is generated by Databricks SDK Code Generator. +func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRequest) *listing.Iterator[ListAccountGroupsRequest, *ListGroupsResponse, Group] { + getNextPage := func(ctx context.Context, req ListAccountGroupsRequest) (*ListGroupsResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListGroupsResponse) []Group { + return resp.Resources + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *AccountGroupsAPI) ListAll(ctx context.Context, request ListAccountGroupsRequest) ([]Group, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -355,6 +371,21 @@ func (a *AccountServicePrincipalsAPI) GetById(ctx context.Context, id string) (* // Gets the set of service principals associated with a Databricks account. // // This method is generated by Databricks SDK Code Generator. +func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAccountServicePrincipalsRequest) *listing.Iterator[ListAccountServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { + getNextPage := func(ctx context.Context, req ListAccountServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListServicePrincipalResponse) []ServicePrincipal { + return resp.Resources + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *AccountServicePrincipalsAPI) ListAll(ctx context.Context, request ListAccountServicePrincipalsRequest) ([]ServicePrincipal, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -517,6 +548,21 @@ func (a *AccountUsersAPI) GetById(ctx context.Context, id string) (*User, error) // Gets details for all the users associated with a Databricks account. // // This method is generated by Databricks SDK Code Generator. +func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequest) *listing.Iterator[ListAccountUsersRequest, *ListUsersResponse, User] { + getNextPage := func(ctx context.Context, req ListAccountUsersRequest) (*ListUsersResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListUsersResponse) []User { + return resp.Resources + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *AccountUsersAPI) ListAll(ctx context.Context, request ListAccountUsersRequest) ([]User, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -706,6 +752,21 @@ func (a *GroupsAPI) GetById(ctx context.Context, id string) (*Group, error) { // Gets all details of the groups associated with the Databricks workspace. // // This method is generated by Databricks SDK Code Generator. +func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listing.Iterator[ListGroupsRequest, *ListGroupsResponse, Group] { + getNextPage := func(ctx context.Context, req ListGroupsRequest) (*ListGroupsResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListGroupsResponse) []Group { + return resp.Resources + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *GroupsAPI) ListAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -984,6 +1045,21 @@ func (a *ServicePrincipalsAPI) GetById(ctx context.Context, id string) (*Service // Gets the set of service principals associated with a Databricks workspace. // // This method is generated by Databricks SDK Code Generator. +func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrincipalsRequest) *listing.Iterator[ListServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { + getNextPage := func(ctx context.Context, req ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListServicePrincipalResponse) []ServicePrincipal { + return resp.Resources + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *ServicePrincipalsAPI) ListAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -1161,6 +1237,21 @@ func (a *UsersAPI) GetPermissions(ctx context.Context) (*PasswordPermissions, er // Gets details for all the users associated with a Databricks workspace. // // This method is generated by Databricks SDK Code Generator. +func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing.Iterator[ListUsersRequest, *ListUsersResponse, User] { + getNextPage := func(ctx context.Context, req ListUsersRequest) (*ListUsersResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListUsersResponse) []User { + return resp.Resources + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *UsersAPI) ListAll(ctx context.Context, request ListUsersRequest) ([]User, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -1324,6 +1415,21 @@ func (a *WorkspaceAssignmentAPI) GetByWorkspaceId(ctx context.Context, workspace // Databricks workspace. // // This method is generated by Databricks SDK Code Generator. +func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspaceAssignmentRequest) *listing.Iterator[ListWorkspaceAssignmentRequest, *PermissionAssignments, PermissionAssignment] { + getNextPage := func(ctx context.Context, req ListWorkspaceAssignmentRequest) (*PermissionAssignments, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *PermissionAssignments) []PermissionAssignment { + return resp.PermissionAssignments + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorkspaceAssignmentRequest) ([]PermissionAssignment, error) { response, err := a.impl.List(ctx, request) if err != nil { diff --git a/service/iam/model.go b/service/iam/model.go index 4d1a0f3d0..8a1ba4cd1 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,7 @@ type Group struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks group ID - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Members []ComplexValue `json:"members,omitempty"` // Container for the group identifier. Workspace local versus account. @@ -1024,7 +1024,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Roles []ComplexValue `json:"roles,omitempty"` diff --git a/service/jobs/api.go b/service/jobs/api.go index 6bbe4c593..f73df8b95 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -9,6 +9,7 @@ import ( "time" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/retries" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -327,6 +328,24 @@ func (a *JobsAPI) GetRunOutputByRunId(ctx context.Context, runId int64) (*RunOut // Retrieves a list of jobs. // // This method is generated by Databricks SDK Code Generator. +func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.Iterator[ListJobsRequest, *ListJobsResponse, BaseJob] { + getNextPage := func(ctx context.Context, req ListJobsRequest) (*ListJobsResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListJobsResponse) []BaseJob { + return resp.Jobs + } + getNextReq := func(resp *ListJobsResponse) ListJobsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJob, error) { var results []BaseJob var totalCount int = 0 @@ -414,6 +433,24 @@ func (a *JobsAPI) GetBySettingsName(ctx context.Context, name string) (*BaseJob, // List runs in descending order by start time. // // This method is generated by Databricks SDK Code Generator. +func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listing.Iterator[ListRunsRequest, *ListRunsResponse, BaseRun] { + getNextPage := func(ctx context.Context, req ListRunsRequest) (*ListRunsResponse, error) { + return a.impl.ListRuns(ctx, req) + } + getItems := func(resp *ListRunsResponse) []BaseRun { + return resp.Runs + } + getNextReq := func(resp *ListRunsResponse) ListRunsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]BaseRun, error) { var results []BaseRun var totalCount int = 0 diff --git a/service/jobs/jobs_usage_test.go b/service/jobs/jobs_usage_test.go index 2130b26b6..d05292d5b 100755 --- a/service/jobs/jobs_usage_test.go +++ b/service/jobs/jobs_usage_test.go @@ -382,6 +382,64 @@ func ExampleJobsAPI_ListAll_jobsApiFullIntegration() { } +func ExampleJobsAPI_ListRuns_jobsApiFullIntegration() { + ctx := context.Background() + w, err := databricks.NewWorkspaceClient() + if err != nil { + panic(err) + } + + notebookPath := func() string { + me, err := w.CurrentUser.Me(ctx) + if err != nil { + panic(err) + } + return filepath.Join("/Users", me.UserName, fmt.Sprintf("sdk-%x", time.Now().UnixNano())) + }() + + clusterId := func() string { + clusterId := os.Getenv("DATABRICKS_CLUSTER_ID") + err := w.Clusters.EnsureClusterIsRunning(ctx, clusterId) + if err != nil { + panic(err) + } + return clusterId + }() + + createdJob, err := w.Jobs.Create(ctx, jobs.CreateJob{ + Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), + Tasks: []jobs.Task{jobs.Task{ + Description: "test", + ExistingClusterId: clusterId, + NotebookTask: &jobs.NotebookTask{ + NotebookPath: notebookPath, + }, + TaskKey: "test", + TimeoutSeconds: 0, + }}, + }) + if err != nil { + panic(err) + } + logger.Infof(ctx, "found %v", createdJob) + + runList, err := w.Jobs.ListRunsAll(ctx, jobs.ListRunsRequest{ + JobId: createdJob.JobId, + }) + if err != nil { + panic(err) + } + logger.Infof(ctx, "found %v", runList) + + // cleanup + + err = w.Jobs.DeleteByJobId(ctx, createdJob.JobId) + if err != nil { + panic(err) + } + +} + func ExampleJobsAPI_RepairRun_jobsApiFullIntegration() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() diff --git a/service/ml/api.go b/service/ml/api.go index eea99d654..6abb0d131 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -7,6 +7,7 @@ import ( "context" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -126,6 +127,24 @@ func (a *ExperimentsAPI) GetExperiment(ctx context.Context, request GetExperimen // Gets a list of all values for the specified metric for a given run. // // This method is generated by Databricks SDK Code Generator. +func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) *listing.Iterator[GetHistoryRequest, *GetMetricHistoryResponse, Metric] { + getNextPage := func(ctx context.Context, req GetHistoryRequest) (*GetMetricHistoryResponse, error) { + return a.impl.GetHistory(ctx, req) + } + getItems := func(resp *GetMetricHistoryResponse) []Metric { + return resp.Metrics + } + getNextReq := func(resp *GetMetricHistoryResponse) GetHistoryRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRequest) ([]Metric, error) { var results []Metric var totalCount int = 0 @@ -207,6 +226,24 @@ func (a *ExperimentsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Ge // specified, the response contains only artifacts with the specified prefix.", // // This method is generated by Databricks SDK Code Generator. +func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifactsRequest) *listing.Iterator[ListArtifactsRequest, *ListArtifactsResponse, FileInfo] { + getNextPage := func(ctx context.Context, req ListArtifactsRequest) (*ListArtifactsResponse, error) { + return a.impl.ListArtifacts(ctx, req) + } + getItems := func(resp *ListArtifactsResponse) []FileInfo { + return resp.Files + } + getNextReq := func(resp *ListArtifactsResponse) ListArtifactsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) { var results []FileInfo ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -234,6 +271,24 @@ func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtif // Gets a list of all experiments. // // This method is generated by Databricks SDK Code Generator. +func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperimentsRequest) *listing.Iterator[ListExperimentsRequest, *ListExperimentsResponse, Experiment] { + getNextPage := func(ctx context.Context, req ListExperimentsRequest) (*ListExperimentsResponse, error) { + return a.impl.ListExperiments(ctx, req) + } + getItems := func(resp *ListExperimentsResponse) []Experiment { + return resp.Experiments + } + getNextReq := func(resp *ListExperimentsResponse) ListExperimentsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) { var results []Experiment var totalCount int = 0 @@ -373,6 +428,24 @@ func (a *ExperimentsAPI) RestoreRuns(ctx context.Context, request RestoreRuns) ( // Searches for experiments that satisfy specified search criteria. // // This method is generated by Databricks SDK Code Generator. +func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchExperiments) *listing.Iterator[SearchExperiments, *SearchExperimentsResponse, Experiment] { + getNextPage := func(ctx context.Context, req SearchExperiments) (*SearchExperimentsResponse, error) { + return a.impl.SearchExperiments(ctx, req) + } + getItems := func(resp *SearchExperimentsResponse) []Experiment { + return resp.Experiments + } + getNextReq := func(resp *SearchExperimentsResponse) SearchExperiments { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) { var results []Experiment ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -402,6 +475,24 @@ func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request Searc // Search expressions can use `mlflowMetric` and `mlflowParam` keys.", // // This method is generated by Databricks SDK Code Generator. +func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *listing.Iterator[SearchRuns, *SearchRunsResponse, Run] { + getNextPage := func(ctx context.Context, req SearchRuns) (*SearchRunsResponse, error) { + return a.impl.SearchRuns(ctx, req) + } + getItems := func(resp *SearchRunsResponse) []Run { + return resp.Runs + } + getNextReq := func(resp *SearchRunsResponse) SearchRuns { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) ([]Run, error) { var results []Run ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -603,6 +694,21 @@ func (a *ModelRegistryAPI) DeleteWebhook(ctx context.Context, request DeleteWebh // Gets the latest version of a registered model. // // This method is generated by Databricks SDK Code Generator. +func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) *listing.Iterator[GetLatestVersionsRequest, *GetLatestVersionsResponse, ModelVersion] { + getNextPage := func(ctx context.Context, req GetLatestVersionsRequest) (*GetLatestVersionsResponse, error) { + return a.impl.GetLatestVersions(ctx, req) + } + getItems := func(resp *GetLatestVersionsResponse) []ModelVersion { + return resp.ModelVersions + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *ModelRegistryAPI) GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) { response, err := a.impl.GetLatestVersions(ctx, request) if err != nil { @@ -676,6 +782,24 @@ func (a *ModelRegistryAPI) GetPermissionsByRegisteredModelId(ctx context.Context // __max_results__. // // This method is generated by Databricks SDK Code Generator. +func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsRequest) *listing.Iterator[ListModelsRequest, *ListModelsResponse, Model] { + getNextPage := func(ctx context.Context, req ListModelsRequest) (*ListModelsResponse, error) { + return a.impl.ListModels(ctx, req) + } + getItems := func(resp *ListModelsResponse) []Model { + return resp.RegisteredModels + } + getNextReq := func(resp *ListModelsResponse) ListModelsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModelsRequest) ([]Model, error) { var results []Model var totalCount int = 0 @@ -710,6 +834,21 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels // Gets a list of all open stage transition requests for the model version. // // This method is generated by Databricks SDK Code Generator. +func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request ListTransitionRequestsRequest) *listing.Iterator[ListTransitionRequestsRequest, *ListTransitionRequestsResponse, Activity] { + getNextPage := func(ctx context.Context, req ListTransitionRequestsRequest) (*ListTransitionRequestsResponse, error) { + return a.impl.ListTransitionRequests(ctx, req) + } + getItems := func(resp *ListTransitionRequestsResponse) []Activity { + return resp.Requests + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, request ListTransitionRequestsRequest) ([]Activity, error) { response, err := a.impl.ListTransitionRequests(ctx, request) if err != nil { @@ -725,6 +864,24 @@ func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, reques // Lists all registry webhooks. // // This method is generated by Databricks SDK Code Generator. +func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhooksRequest) *listing.Iterator[ListWebhooksRequest, *ListRegistryWebhooks, RegistryWebhook] { + getNextPage := func(ctx context.Context, req ListWebhooksRequest) (*ListRegistryWebhooks, error) { + return a.impl.ListWebhooks(ctx, req) + } + getItems := func(resp *ListRegistryWebhooks) []RegistryWebhook { + return resp.Webhooks + } + getNextReq := func(resp *ListRegistryWebhooks) ListWebhooksRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebhooksRequest) ([]RegistryWebhook, error) { var results []RegistryWebhook ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -766,6 +923,24 @@ func (a *ModelRegistryAPI) RenameModel(ctx context.Context, request RenameModelR // Searches for specific model versions based on the supplied __filter__. // // This method is generated by Databricks SDK Code Generator. +func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request SearchModelVersionsRequest) *listing.Iterator[SearchModelVersionsRequest, *SearchModelVersionsResponse, ModelVersion] { + getNextPage := func(ctx context.Context, req SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) { + return a.impl.SearchModelVersions(ctx, req) + } + getItems := func(resp *SearchModelVersionsResponse) []ModelVersion { + return resp.ModelVersions + } + getNextReq := func(resp *SearchModelVersionsResponse) SearchModelVersionsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) { var results []ModelVersion var totalCount int = 0 @@ -800,6 +975,24 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S // Search for registered models based on the specified __filter__. // // This method is generated by Databricks SDK Code Generator. +func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModelsRequest) *listing.Iterator[SearchModelsRequest, *SearchModelsResponse, Model] { + getNextPage := func(ctx context.Context, req SearchModelsRequest) (*SearchModelsResponse, error) { + return a.impl.SearchModels(ctx, req) + } + getItems := func(resp *SearchModelsResponse) []Model { + return resp.RegisteredModels + } + getNextReq := func(resp *SearchModelsResponse) SearchModelsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchModelsRequest) ([]Model, error) { var results []Model var totalCount int = 0 diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index 72de73538..7199cd404 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -75,7 +75,7 @@ func ExampleModelRegistryAPI_CreateModel_models() { } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -92,7 +92,7 @@ func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_modelVersions() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 3d6e0c382..dc3938bde 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -7,6 +7,7 @@ import ( "context" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -89,6 +90,21 @@ func (a *CustomAppIntegrationAPI) GetByIntegrationId(ctx context.Context, integr // account // // This method is generated by Databricks SDK Code Generator. +func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetCustomAppIntegrationsOutput, GetCustomAppIntegrationOutput] { + getNextPage := func(ctx context.Context, req struct{}) (*GetCustomAppIntegrationsOutput, error) { + return a.impl.List(ctx) + } + getItems := func(resp *GetCustomAppIntegrationsOutput) []GetCustomAppIntegrationOutput { + return resp.Apps + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIntegrationOutput, error) { response, err := a.impl.List(ctx) if err != nil { @@ -196,6 +212,24 @@ func (a *OAuthPublishedAppsAPI) Impl() OAuthPublishedAppsService { // Get all the available published OAuth apps in Databricks. // // This method is generated by Databricks SDK Code Generator. +func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPublishedAppsRequest) *listing.Iterator[ListOAuthPublishedAppsRequest, *GetPublishedAppsOutput, PublishedAppOutput] { + getNextPage := func(ctx context.Context, req ListOAuthPublishedAppsRequest) (*GetPublishedAppsOutput, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *GetPublishedAppsOutput) []PublishedAppOutput { + return resp.Apps + } + getNextReq := func(resp *GetPublishedAppsOutput) ListOAuthPublishedAppsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPublishedAppsRequest) ([]PublishedAppOutput, error) { var results []PublishedAppOutput var totalCount int64 = 0 @@ -304,6 +338,21 @@ func (a *PublishedAppIntegrationAPI) GetByIntegrationId(ctx context.Context, int // account // // This method is generated by Databricks SDK Code Generator. +func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetPublishedAppIntegrationsOutput, GetPublishedAppIntegrationOutput] { + getNextPage := func(ctx context.Context, req struct{}) (*GetPublishedAppIntegrationsOutput, error) { + return a.impl.List(ctx) + } + getItems := func(resp *GetPublishedAppIntegrationsOutput) []GetPublishedAppIntegrationOutput { + return resp.Apps + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishedAppIntegrationOutput, error) { response, err := a.impl.List(ctx) if err != nil { @@ -390,6 +439,21 @@ func (a *ServicePrincipalSecretsAPI) DeleteByServicePrincipalIdAndSecretId(ctx c // the secret values. // // This method is generated by Databricks SDK Code Generator. +func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServicePrincipalSecretsRequest) *listing.Iterator[ListServicePrincipalSecretsRequest, *ListServicePrincipalSecretsResponse, SecretInfo] { + getNextPage := func(ctx context.Context, req ListServicePrincipalSecretsRequest) (*ListServicePrincipalSecretsResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListServicePrincipalSecretsResponse) []SecretInfo { + return resp.Secrets + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *ServicePrincipalSecretsAPI) ListAll(ctx context.Context, request ListServicePrincipalSecretsRequest) ([]SecretInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 463af5059..0bb318f16 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -9,6 +9,7 @@ import ( "time" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/retries" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -253,6 +254,24 @@ func (a *PipelinesAPI) GetUpdateByPipelineIdAndUpdateId(ctx context.Context, pip // Retrieves events for a pipeline. // // This method is generated by Databricks SDK Code Generator. +func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipelineEventsRequest) *listing.Iterator[ListPipelineEventsRequest, *ListPipelineEventsResponse, PipelineEvent] { + getNextPage := func(ctx context.Context, req ListPipelineEventsRequest) (*ListPipelineEventsResponse, error) { + return a.impl.ListPipelineEvents(ctx, req) + } + getItems := func(resp *ListPipelineEventsResponse) []PipelineEvent { + return resp.Events + } + getNextReq := func(resp *ListPipelineEventsResponse) ListPipelineEventsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPipelineEventsRequest) ([]PipelineEvent, error) { var results []PipelineEvent var totalCount int = 0 @@ -296,6 +315,24 @@ func (a *PipelinesAPI) ListPipelineEventsByPipelineId(ctx context.Context, pipel // Lists pipelines defined in the Delta Live Tables system. // // This method is generated by Databricks SDK Code Generator. +func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesRequest) *listing.Iterator[ListPipelinesRequest, *ListPipelinesResponse, PipelineStateInfo] { + getNextPage := func(ctx context.Context, req ListPipelinesRequest) (*ListPipelinesResponse, error) { + return a.impl.ListPipelines(ctx, req) + } + getItems := func(resp *ListPipelinesResponse) []PipelineStateInfo { + return resp.Statuses + } + getNextReq := func(resp *ListPipelinesResponse) ListPipelinesRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelinesRequest) ([]PipelineStateInfo, error) { var results []PipelineStateInfo var totalCount int = 0 diff --git a/service/serving/api.go b/service/serving/api.go index 067017fbf..ec5aeb7eb 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -9,6 +9,7 @@ import ( "time" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/retries" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -252,6 +253,21 @@ func (a *ServingEndpointsAPI) GetPermissionsByServingEndpointId(ctx context.Cont // Retrieve all serving endpoints. // // This method is generated by Databricks SDK Code Generator. +func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListEndpointsResponse, ServingEndpoint] { + getNextPage := func(ctx context.Context, req struct{}) (*ListEndpointsResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListEndpointsResponse) []ServingEndpoint { + return resp.Endpoints + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *ServingEndpointsAPI) ListAll(ctx context.Context) ([]ServingEndpoint, error) { response, err := a.impl.List(ctx) if err != nil { diff --git a/service/settings/api.go b/service/settings/api.go index e4129f4cb..cc5564121 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -116,6 +117,21 @@ func (a *AccountIpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAcc // Gets all IP access lists for the specified account. // // This method is generated by Databricks SDK Code Generator. +func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetIpAccessListsResponse, IpAccessListInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*GetIpAccessListsResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *GetIpAccessListsResponse) []IpAccessListInfo { + return resp.IpAccessLists + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *AccountIpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { response, err := a.impl.List(ctx) if err != nil { @@ -412,6 +428,21 @@ func (a *IpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAccessList // Gets all IP access lists for the specified workspace. // // This method is generated by Databricks SDK Code Generator. +func (a *IpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListIpAccessListResponse, IpAccessListInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListIpAccessListResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListIpAccessListResponse) []IpAccessListInfo { + return resp.IpAccessLists + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *IpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { response, err := a.impl.List(ctx) if err != nil { @@ -654,6 +685,21 @@ func (a *TokenManagementAPI) GetPermissions(ctx context.Context) (*TokenPermissi // Lists all tokens associated with the specified workspace or user. // // This method is generated by Databricks SDK Code Generator. +func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManagementRequest) *listing.Iterator[ListTokenManagementRequest, *ListTokensResponse, TokenInfo] { + getNextPage := func(ctx context.Context, req ListTokenManagementRequest) (*ListTokensResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListTokensResponse) []TokenInfo { + return resp.TokenInfos + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *TokenManagementAPI) ListAll(ctx context.Context, request ListTokenManagementRequest) ([]TokenInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -796,6 +842,21 @@ func (a *TokensAPI) DeleteByTokenId(ctx context.Context, tokenId string) error { // Lists all the valid tokens for a user-workspace pair. // // This method is generated by Databricks SDK Code Generator. +func (a *TokensAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListTokensResponse, TokenInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListTokensResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListTokensResponse) []TokenInfo { + return resp.TokenInfos + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *TokensAPI) ListAll(ctx context.Context) ([]TokenInfo, error) { response, err := a.impl.List(ctx) if err != nil { diff --git a/service/sharing/api.go b/service/sharing/api.go index de305dc5c..ea9133e2d 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -95,6 +96,24 @@ func (a *CleanRoomsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Clea // a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. +func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) *listing.Iterator[ListCleanRoomsRequest, *ListCleanRoomsResponse, CleanRoomInfo] { + getNextPage := func(ctx context.Context, req ListCleanRoomsRequest) (*ListCleanRoomsResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListCleanRoomsResponse) []CleanRoomInfo { + return resp.CleanRooms + } + getNextReq := func(resp *ListCleanRoomsResponse) ListCleanRoomsRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsRequest) ([]CleanRoomInfo, error) { var results []CleanRoomInfo var totalCount int = 0 @@ -228,6 +247,21 @@ func (a *ProvidersAPI) GetByName(ctx context.Context, name string) (*ProviderInf // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. +func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) *listing.Iterator[ListProvidersRequest, *ListProvidersResponse, ProviderInfo] { + getNextPage := func(ctx context.Context, req ListProvidersRequest) (*ListProvidersResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListProvidersResponse) []ProviderInfo { + return resp.Providers + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *ProvidersAPI) ListAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -268,6 +302,21 @@ func (a *ProvidersAPI) ProviderInfoNameToMetastoreIdMap(ctx context.Context, req // * the caller is a metastore admin, or * the caller is the owner. // // This method is generated by Databricks SDK Code Generator. +func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest) *listing.Iterator[ListSharesRequest, *ListProviderSharesResponse, ProviderShare] { + getNextPage := func(ctx context.Context, req ListSharesRequest) (*ListProviderSharesResponse, error) { + return a.impl.ListShares(ctx, req) + } + getItems := func(resp *ListProviderSharesResponse) []ProviderShare { + return resp.Shares + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *ProvidersAPI) ListSharesAll(ctx context.Context, request ListSharesRequest) ([]ProviderShare, error) { response, err := a.impl.ListShares(ctx, request) if err != nil { @@ -465,6 +514,21 @@ func (a *RecipientsAPI) GetByName(ctx context.Context, name string) (*RecipientI // guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. +func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) *listing.Iterator[ListRecipientsRequest, *ListRecipientsResponse, RecipientInfo] { + getNextPage := func(ctx context.Context, req ListRecipientsRequest) (*ListRecipientsResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListRecipientsResponse) []RecipientInfo { + return resp.Recipients + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *RecipientsAPI) ListAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { @@ -617,6 +681,21 @@ func (a *SharesAPI) GetByName(ctx context.Context, name string) (*ShareInfo, err // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. +func (a *SharesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListSharesResponse, ShareInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListSharesResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *ListSharesResponse) []ShareInfo { + return resp.Shares + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *SharesAPI) ListAll(ctx context.Context) ([]ShareInfo, error) { response, err := a.impl.List(ctx) if err != nil { diff --git a/service/sql/api.go b/service/sql/api.go index 5075caae7..d7222bd19 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -9,6 +9,7 @@ import ( "time" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/retries" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -285,6 +286,24 @@ func (a *DashboardsAPI) GetByDashboardId(ctx context.Context, dashboardId string // Fetch a paginated list of dashboard objects. // // This method is generated by Databricks SDK Code Generator. +func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) *listing.Iterator[ListDashboardsRequest, *ListResponse, Dashboard] { + getNextPage := func(ctx context.Context, req ListDashboardsRequest) (*ListResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListResponse) []Dashboard { + return resp.Results + } + getNextReq := func(resp *ListResponse) ListDashboardsRequest { + request.Page = resp.Page + 1 + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { var results []Dashboard var totalCount int = 0 @@ -641,6 +660,24 @@ func (a *QueriesAPI) GetByQueryId(ctx context.Context, queryId string) (*Query, // term. // // This method is generated by Databricks SDK Code Generator. +func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *listing.Iterator[ListQueriesRequest, *QueryList, Query] { + getNextPage := func(ctx context.Context, req ListQueriesRequest) (*QueryList, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *QueryList) []Query { + return resp.Results + } + getNextReq := func(resp *QueryList) ListQueriesRequest { + request.Page = resp.Page + 1 + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { var results []Query var totalCount int = 0 @@ -780,6 +817,24 @@ func (a *QueryHistoryAPI) Impl() QueryHistoryService { // You can filter by user ID, warehouse ID, status, and time range. // // This method is generated by Databricks SDK Code Generator. +func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequest) *listing.Iterator[ListQueryHistoryRequest, *ListQueriesResponse, QueryInfo] { + getNextPage := func(ctx context.Context, req ListQueryHistoryRequest) (*ListQueriesResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListQueriesResponse) []QueryInfo { + return resp.Res + } + getNextReq := func(resp *ListQueriesResponse) ListQueryHistoryRequest { + request.PageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) { var results []QueryInfo var totalCount int = 0 @@ -1375,6 +1430,21 @@ func (a *WarehousesAPI) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWo // Lists all SQL warehouses that a user has manager permissions on. // // This method is generated by Databricks SDK Code Generator. +func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) *listing.Iterator[ListWarehousesRequest, *ListWarehousesResponse, EndpointInfo] { + getNextPage := func(ctx context.Context, req ListWarehousesRequest) (*ListWarehousesResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListWarehousesResponse) []EndpointInfo { + return resp.Warehouses + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *WarehousesAPI) ListAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { diff --git a/service/sql/model.go b/service/sql/model.go index 8e2fc3298..d4db5f8a3 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -280,6 +280,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/workspace/api.go b/service/workspace/api.go index 2c9d57db3..c1bd97d00 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/databricks/databricks-sdk-go/client" + "github.com/databricks/databricks-sdk-go/listing" "github.com/databricks/databricks-sdk-go/useragent" ) @@ -91,6 +92,21 @@ func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId // supported. // // This method is generated by Databricks SDK Code Generator. +func (a *GitCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetCredentialsResponse, CredentialInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*GetCredentialsResponse, error) { + return a.impl.List(ctx) + } + getItems := func(resp *GetCredentialsResponse) []CredentialInfo { + return resp.Credentials + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error) { response, err := a.impl.List(ctx) if err != nil { @@ -276,6 +292,24 @@ func (a *ReposAPI) GetPermissionsByRepoId(ctx context.Context, repoId string) (* // paginated with each page containing twenty repos. // // This method is generated by Databricks SDK Code Generator. +func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing.Iterator[ListReposRequest, *ListReposResponse, RepoInfo] { + getNextPage := func(ctx context.Context, req ListReposRequest) (*ListReposResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListReposResponse) []RepoInfo { + return resp.Repos + } + getNextReq := func(resp *ListReposResponse) ListReposRequest { + request.NextPageToken = resp.NextPageToken + return request + } + return listing.NewIterator( + request, + getNextPage, + getItems, + getNextReq) +} + func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error) { var results []RepoInfo ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -510,6 +544,21 @@ func (a *SecretsAPI) GetSecret(ctx context.Context, request GetSecretRequest) (* // call. // // This method is generated by Databricks SDK Code Generator. +func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *listing.Iterator[ListAclsRequest, *ListAclsResponse, AclItem] { + getNextPage := func(ctx context.Context, req ListAclsRequest) (*ListAclsResponse, error) { + return a.impl.ListAcls(ctx, req) + } + getItems := func(resp *ListAclsResponse) []AclItem { + return resp.Items + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) { response, err := a.impl.ListAcls(ctx, request) if err != nil { @@ -540,6 +589,21 @@ func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAc // API call. // // This method is generated by Databricks SDK Code Generator. +func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.Iterator[struct{}, *ListScopesResponse, SecretScope] { + getNextPage := func(ctx context.Context, req struct{}) (*ListScopesResponse, error) { + return a.impl.ListScopes(ctx) + } + getItems := func(resp *ListScopesResponse) []SecretScope { + return resp.Scopes + } + + return listing.NewIterator( + struct{}{}, + getNextPage, + getItems, + nil) +} + func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { response, err := a.impl.ListScopes(ctx) if err != nil { @@ -560,6 +624,21 @@ func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { // call. // // This method is generated by Databricks SDK Code Generator. +func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) *listing.Iterator[ListSecretsRequest, *ListSecretsResponse, SecretMetadata] { + getNextPage := func(ctx context.Context, req ListSecretsRequest) (*ListSecretsResponse, error) { + return a.impl.ListSecrets(ctx, req) + } + getItems := func(resp *ListSecretsResponse) []SecretMetadata { + return resp.Secrets + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) { response, err := a.impl.ListSecrets(ctx, request) if err != nil { @@ -773,6 +852,21 @@ func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error { // `RESOURCE_DOES_NOT_EXIST`. // // This method is generated by Databricks SDK Code Generator. +func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) *listing.Iterator[ListWorkspaceRequest, *ListResponse, ObjectInfo] { + getNextPage := func(ctx context.Context, req ListWorkspaceRequest) (*ListResponse, error) { + return a.impl.List(ctx, req) + } + getItems := func(resp *ListResponse) []ObjectInfo { + return resp.Objects + } + + return listing.NewIterator( + request, + getNextPage, + getItems, + nil) +} + func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error) { response, err := a.impl.List(ctx, request) if err != nil { From 320c7fe4910091e7688c6caaac2b01f1f718450a Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 19 Oct 2023 15:37:00 +0200 Subject: [PATCH 03/24] Implement ListAll in terms of List --- .codegen/api.go.tmpl | 82 +++----- listing/listing.go | 34 +++- service/billing/api.go | 26 ++- service/catalog/api.go | 319 ++++++++++++++++++++----------- service/compute/api.go | 160 ++++++++++------ service/files/api.go | 14 +- service/iam/api.go | 91 +++++++-- service/iam/model.go | 2 +- service/jobs/api.go | 88 ++++----- service/ml/api.go | 402 +++++++++++++++++++++------------------ service/oauth2/api.go | 83 +++++--- service/pipelines/api.go | 88 ++++----- service/serving/api.go | 13 +- service/settings/api.go | 52 ++++- service/sharing/api.go | 96 +++++++--- service/sql/api.go | 149 ++++++++------- service/sql/model.go | 1 - service/workspace/api.go | 104 +++++++--- 18 files changed, 1106 insertions(+), 698 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index b600668f9..1ec13cc82 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -164,16 +164,26 @@ 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}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) *listing.Iterator[{{if .Request}}{{.Request.PascalName}}{{else}}struct{}{{end}}, *{{ .Response.PascalName }}, {{template "type" .Pagination.Entity}}] { + {{if eq .Pagination.Increment 1 -}} + request.{{.Pagination.Offset.PascalName}} = 1 // start iterating from the first page + {{end}} getNextPage := func(ctx context.Context, req {{if .Request}}{{.Request.PascalName}}{{else}}struct{}{{end}}) (*{{ .Response.PascalName }}, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.{{.PascalName}}(ctx{{if .Request}}, req{{end}}) } getItems := func(resp *{{ .Response.PascalName }}) []{{ template "type" .Pagination.Entity }} { return {{if .Pagination.Results}}resp.{{.Pagination.Results.PascalName}}{{else}}resp{{end}} } {{if .Pagination.MultiRequest -}} - getNextReq := func(resp *{{ .Response.PascalName }}) {{.Request.PascalName}} { + getNextReq := func(resp *{{ .Response.PascalName }}) ({{.Request.PascalName}}, listing.ListingStatus) { {{if .Pagination.Token -}} request.{{.Pagination.Token.PollField.PascalName}} = resp.{{.Pagination.Token.Bind.PascalName}} + var status listing.ListingStatus + if resp.{{.Pagination.Token.Bind.PascalName}} == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } {{- else if eq .Pagination.Increment 1 -}} request.{{.Pagination.Offset.PascalName}} = resp.{{.Pagination.Offset.PascalName}} + 1 {{- else if eq .Path "/api/2.0/clusters/events" -}} @@ -181,7 +191,7 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} {{- else -}} request.{{.Pagination.Offset.PascalName}} = resp.{{.Pagination.Offset.PascalName}} + {{template "type" .Pagination.Offset.Entity}}(len(resp.{{.Pagination.Results.PascalName}})) {{- end}} - return request + return request, {{if .Pagination.Token}}status{{else}}listing.ListingStatusCheckResult{{end}} } {{- end}} return listing.NewIterator( @@ -192,75 +202,39 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} } func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{ template "type" .Pagination.Entity }}, error) { - {{if .Pagination.MultiRequest -}} - var results []{{.Pagination.Entity.PascalName}} + var results []{{ template "type" .Pagination.Entity }} {{ if .Pagination.Limit -}} var totalCount {{template "type" .Pagination.Limit.Entity}} = 0 + limit := request.{{.Pagination.Limit.PascalName}} {{ end -}} - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") + iter := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) {{if .NeedsOffsetDedupe -}} // 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 - {{end}}for { - response, err := a.impl.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) - if err != nil { - return nil, err - } - if len(response.{{.Pagination.Results.PascalName}}) == 0 { - break - } - for _, v := range response.{{.Pagination.Results.PascalName}} { - {{- if .NeedsOffsetDedupe -}} - id := v{{ template "field-path" .IdFieldPath }} - if seen[id] { - // item was added during iteration - continue - } - seen[id] = true - {{- end}} - results = append(results, v) + {{end -}} + var err error + var next {{ template "type" .Pagination.Entity }} + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + {{ if .NeedsOffsetDedupe -}} + id := next{{ template "field-path" .IdFieldPath }} + if seen[id] { + // item was added during iteration + continue } - {{ if and .Pagination.Token .Pagination.Limit -}} - count := {{template "type" .Pagination.Limit.Entity}}(len(response.{{.Pagination.Results.PascalName}})) - totalCount += count - {{ else if .Pagination.Offset -}} - count := {{template "type" .Pagination.Offset.Entity}}(len(response.{{.Pagination.Results.PascalName}})) - totalCount += count - {{ end -}} - {{if eq .Path "/api/2.0/clusters/events" -}} - if response.NextPage == nil { - break - } - request = *response.NextPage - {{- else if .Pagination.Token -}} - request.{{.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}}++ - {{- else -}} - request.{{.Pagination.Offset.PascalName}} += {{template "type" .Pagination.Offset.Entity}}(len(response.{{.Pagination.Results.PascalName}})) + seen[id] = true {{- end}} + results = append(results, next) {{ if .Pagination.Limit -}} - limit := request.{{.Pagination.Limit.PascalName}} + totalCount++ if limit > 0 && totalCount >= limit { break } {{- end -}} } - return results, nil - {{- else if .Pagination.Results -}} - response, err := a.impl.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) if err != nil { return nil, err } - return response.{{.Pagination.Results.PascalName}}, nil - {{- else -}} - return a.impl.{{.PascalName}}(ctx, request) - {{- end}} + return results, err } {{end}}{{if .NamedIdMap}} // {{.NamedIdMap.PascalName}} calls [{{.Service.Name}}API.{{.PascalName}}{{if not .NamedIdMap.Direct}}All{{end -}}] and creates a map of results with [{{.NamedIdMap.Entity.PascalName}}]{{ template "field-path" .NamedIdMap.NamePath }} as key and [{{.NamedIdMap.Entity.PascalName}}]{{ template "field-path" .NamedIdMap.IdPath}} as value. diff --git a/listing/listing.go b/listing/listing.go index be74b841d..708cf3f54 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -5,12 +5,31 @@ import ( "errors" ) +type ListingStatus int + +const ( + // ListingStatusExhausted indicates that the iterator is exhausted and + // there are no more items to be fetched. + ListingStatusExhausted ListingStatus = iota + // ListingStatusNotExhausted indicates that the iterator is not exhausted + // and there are more items to be fetched. + ListingStatusNotExhausted ListingStatus = iota + // ListingStatusCheckResult indicates that the iterator is exhausted if and + // only if there are no results returned. + ListingStatusCheckResult ListingStatus = iota +) + // Use struct{} for Req to indicate one-shot iterator. type Iterator[Req, Resp, T any] struct { - nextReq Req - getNextPage func(context.Context, Req) (Resp, error) - getItems func(Resp) []T - getNextReq func(Resp) Req + nextReq Req + getNextPage func(context.Context, Req) (Resp, error) + getItems func(Resp) []T + + // getNextReq is used to get the next request to be used in the next page. + // The returned boolean value indicates whether the iterator is exhausted + // without needing to fetch the next page (e.g. token-based pagination where + // no next page token is provided in the response). + getNextReq func(Resp) (Req, ListingStatus) currentPage []T currentPageIdx int isExhausted bool @@ -22,7 +41,7 @@ func NewIterator[Req, Resp, T any]( nextReq Req, getNextPage func(context.Context, Req) (Resp, error), getItems func(Resp) []T, - getNextReq func(Resp) Req, + getNextReq func(Resp) (Req, ListingStatus), ) *Iterator[Req, Resp, T] { return &Iterator[Req, Resp, T]{ nextReq: nextReq, @@ -47,8 +66,9 @@ func (i *Iterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) (bool items := i.getItems(resp) i.currentPage = items i.currentPageIdx = 0 - i.nextReq = i.getNextReq(resp) - if !i.isExhausted && len(items) == 0 { + var status ListingStatus + i.nextReq, status = i.getNextReq(resp) + if !i.isExhausted && (status == ListingStatusExhausted || (status == ListingStatusCheckResult && len(items) == 0)) { i.isExhausted = true } return !i.isExhausted, err diff --git a/service/billing/api.go b/service/billing/api.go index 4713e3a26..7ec3c53d6 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -132,7 +132,9 @@ func (a *BudgetsAPI) GetByBudgetId(ctx context.Context, budgetId string) (*Wrapp // // This method is generated by Databricks SDK Code Generator. func (a *BudgetsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *BudgetList, BudgetWithStatus] { + getNextPage := func(ctx context.Context, req struct{}) (*BudgetList, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *BudgetList) []BudgetWithStatus { @@ -147,11 +149,18 @@ func (a *BudgetsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *Budg } func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { - response, err := a.impl.List(ctx) + var results []BudgetWithStatus + iter := a.List(ctx) + var err error + var next BudgetWithStatus + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Budgets, nil + return results, err } // BudgetWithStatusNameToBudgetIdMap calls [BudgetsAPI.ListAll] and creates a map of results with [BudgetWithStatus].Name as key and [BudgetWithStatus].BudgetId as value. @@ -358,7 +367,9 @@ func (a *LogDeliveryAPI) GetByLogDeliveryConfigurationId(ctx context.Context, lo // // This method is generated by Databricks SDK Code Generator. func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryRequest) *listing.Iterator[ListLogDeliveryRequest, *WrappedLogDeliveryConfigurations, LogDeliveryConfiguration] { + getNextPage := func(ctx context.Context, req ListLogDeliveryRequest) (*WrappedLogDeliveryConfigurations, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *WrappedLogDeliveryConfigurations) []LogDeliveryConfiguration { @@ -373,11 +384,18 @@ func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryReques } func (a *LogDeliveryAPI) ListAll(ctx context.Context, request ListLogDeliveryRequest) ([]LogDeliveryConfiguration, error) { - response, err := a.impl.List(ctx, request) + var results []LogDeliveryConfiguration + iter := a.List(ctx, request) + var err error + var next LogDeliveryConfiguration + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.LogDeliveryConfigurations, nil + return results, err } // LogDeliveryConfigurationConfigNameToConfigIdMap calls [LogDeliveryAPI.ListAll] and creates a map of results with [LogDeliveryConfiguration].ConfigName as key and [LogDeliveryConfiguration].ConfigId as value. diff --git a/service/catalog/api.go b/service/catalog/api.go index 2da3c1676..8c6b74968 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -94,7 +94,9 @@ func (a *AccountMetastoreAssignmentsAPI) GetByWorkspaceId(ctx context.Context, w // // This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) *listing.Iterator[ListAccountMetastoreAssignmentsRequest, *ListAccountMetastoreAssignmentsResponse, int64] { + getNextPage := func(ctx context.Context, req ListAccountMetastoreAssignmentsRequest) (*ListAccountMetastoreAssignmentsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListAccountMetastoreAssignmentsResponse) []int64 { @@ -109,11 +111,18 @@ func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListA } func (a *AccountMetastoreAssignmentsAPI) ListAll(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) ([]int64, error) { - response, err := a.impl.List(ctx, request) + var results []int64 + iter := a.List(ctx, request) + var err error + var next int64 + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.WorkspaceIds, nil + return results, err } // Get all workspaces assigned to a metastore. @@ -207,7 +216,9 @@ func (a *AccountMetastoresAPI) GetByMetastoreId(ctx context.Context, metastoreId // // This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListMetastoresResponse, MetastoreInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListMetastoresResponse) []MetastoreInfo { @@ -222,11 +233,18 @@ func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.Iterator[struc } func (a *AccountMetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { - response, err := a.impl.List(ctx) + var results []MetastoreInfo + iter := a.List(ctx) + var err error + var next MetastoreInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Metastores, nil + return results, err } // Update a metastore. @@ -543,7 +561,9 @@ func (a *CatalogsAPI) GetByName(ctx context.Context, name string) (*CatalogInfo, // // This method is generated by Databricks SDK Code Generator. func (a *CatalogsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListCatalogsResponse, CatalogInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListCatalogsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListCatalogsResponse) []CatalogInfo { @@ -558,11 +578,18 @@ func (a *CatalogsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *Lis } func (a *CatalogsAPI) ListAll(ctx context.Context) ([]CatalogInfo, error) { - response, err := a.impl.List(ctx) + var results []CatalogInfo + iter := a.List(ctx) + var err error + var next CatalogInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Catalogs, nil + return results, err } // Update a catalog. @@ -660,7 +687,9 @@ func (a *ConnectionsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Con // // This method is generated by Databricks SDK Code Generator. func (a *ConnectionsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListConnectionsResponse, ConnectionInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListConnectionsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListConnectionsResponse) []ConnectionInfo { @@ -675,11 +704,18 @@ func (a *ConnectionsAPI) List(ctx context.Context) *listing.Iterator[struct{}, * } func (a *ConnectionsAPI) ListAll(ctx context.Context) ([]ConnectionInfo, error) { - response, err := a.impl.List(ctx) + var results []ConnectionInfo + iter := a.List(ctx) + var err error + var next ConnectionInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Connections, nil + return results, err } // ConnectionInfoNameToFullNameMap calls [ConnectionsAPI.ListAll] and creates a map of results with [ConnectionInfo].Name as key and [ConnectionInfo].FullName as value. @@ -838,7 +874,9 @@ func (a *ExternalLocationsAPI) GetByName(ctx context.Context, name string) (*Ext // // This method is generated by Databricks SDK Code Generator. func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListExternalLocationsResponse, ExternalLocationInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListExternalLocationsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListExternalLocationsResponse) []ExternalLocationInfo { @@ -853,11 +891,18 @@ func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.Iterator[struc } func (a *ExternalLocationsAPI) ListAll(ctx context.Context) ([]ExternalLocationInfo, error) { - response, err := a.impl.List(ctx) + var results []ExternalLocationInfo + iter := a.List(ctx) + var err error + var next ExternalLocationInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.ExternalLocations, nil + return results, err } // Update an external location. @@ -980,7 +1025,9 @@ func (a *FunctionsAPI) GetByName(ctx context.Context, name string) (*FunctionInf // // This method is generated by Databricks SDK Code Generator. func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) *listing.Iterator[ListFunctionsRequest, *ListFunctionsResponse, FunctionInfo] { + getNextPage := func(ctx context.Context, req ListFunctionsRequest) (*ListFunctionsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListFunctionsResponse) []FunctionInfo { @@ -995,11 +1042,18 @@ func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) * } func (a *FunctionsAPI) ListAll(ctx context.Context, request ListFunctionsRequest) ([]FunctionInfo, error) { - response, err := a.impl.List(ctx, request) + var results []FunctionInfo + iter := a.List(ctx, request) + var err error + var next FunctionInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Functions, nil + return results, err } // FunctionInfoNameToFullNameMap calls [FunctionsAPI.ListAll] and creates a map of results with [FunctionInfo].Name as key and [FunctionInfo].FullName as value. @@ -1231,7 +1285,9 @@ func (a *MetastoresAPI) GetById(ctx context.Context, id string) (*MetastoreInfo, // // This method is generated by Databricks SDK Code Generator. func (a *MetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListMetastoresResponse, MetastoreInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListMetastoresResponse) []MetastoreInfo { @@ -1246,11 +1302,18 @@ func (a *MetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *L } func (a *MetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { - response, err := a.impl.List(ctx) + var results []MetastoreInfo + iter := a.List(ctx) + var err error + var next MetastoreInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Metastores, nil + return results, err } // MetastoreInfoNameToMetastoreIdMap calls [MetastoresAPI.ListAll] and creates a map of results with [MetastoreInfo].Name as key and [MetastoreInfo].MetastoreId as value. @@ -1482,15 +1545,23 @@ func (a *ModelVersionsAPI) GetByAliasByFullNameAndAlias(ctx context.Context, ful // // This method is generated by Databricks SDK Code Generator. func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRequest) *listing.Iterator[ListModelVersionsRequest, *ListModelVersionsResponse, ModelVersionInfo] { + getNextPage := func(ctx context.Context, req ListModelVersionsRequest) (*ListModelVersionsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListModelVersionsResponse) []ModelVersionInfo { return resp.ModelVersions } - getNextReq := func(resp *ListModelVersionsResponse) ListModelVersionsRequest { + getNextReq := func(resp *ListModelVersionsResponse) (ListModelVersionsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -1502,30 +1573,22 @@ func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRe func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersionsRequest) ([]ModelVersionInfo, error) { var results []ModelVersionInfo var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err - } - if len(response.ModelVersions) == 0 { - break - } - for _, v := range response.ModelVersions { - results = append(results, v) - } - count := int(len(response.ModelVersions)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.List(ctx, request) + var err error + var next ModelVersionInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // List Model Versions. @@ -1733,15 +1796,23 @@ func (a *RegisteredModelsAPI) GetByFullName(ctx context.Context, fullName string // // This method is generated by Databricks SDK Code Generator. func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) *listing.Iterator[ListRegisteredModelsRequest, *ListRegisteredModelsResponse, RegisteredModelInfo] { + getNextPage := func(ctx context.Context, req ListRegisteredModelsRequest) (*ListRegisteredModelsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListRegisteredModelsResponse) []RegisteredModelInfo { return resp.RegisteredModels } - getNextReq := func(resp *ListRegisteredModelsResponse) ListRegisteredModelsRequest { + getNextReq := func(resp *ListRegisteredModelsResponse) (ListRegisteredModelsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -1753,30 +1824,22 @@ func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredMo func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegisteredModelsRequest) ([]RegisteredModelInfo, error) { var results []RegisteredModelInfo var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err - } - if len(response.RegisteredModels) == 0 { - break - } - for _, v := range response.RegisteredModels { - results = append(results, v) - } - count := int(len(response.RegisteredModels)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.List(ctx, request) + var err error + var next RegisteredModelInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // RegisteredModelInfoNameToFullNameMap calls [RegisteredModelsAPI.ListAll] and creates a map of results with [RegisteredModelInfo].Name as key and [RegisteredModelInfo].FullName as value. @@ -1947,7 +2010,9 @@ func (a *SchemasAPI) GetByFullName(ctx context.Context, fullName string) (*Schem // // This method is generated by Databricks SDK Code Generator. func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *listing.Iterator[ListSchemasRequest, *ListSchemasResponse, SchemaInfo] { + getNextPage := func(ctx context.Context, req ListSchemasRequest) (*ListSchemasResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListSchemasResponse) []SchemaInfo { @@ -1962,11 +2027,18 @@ func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *list } func (a *SchemasAPI) ListAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) { - response, err := a.impl.List(ctx, request) + var results []SchemaInfo + iter := a.List(ctx, request) + var err error + var next SchemaInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Schemas, nil + return results, err } // SchemaInfoNameToFullNameMap calls [SchemasAPI.ListAll] and creates a map of results with [SchemaInfo].Name as key and [SchemaInfo].FullName as value. @@ -2127,7 +2199,9 @@ func (a *StorageCredentialsAPI) GetByName(ctx context.Context, name string) (*St // // This method is generated by Databricks SDK Code Generator. func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListStorageCredentialsResponse, StorageCredentialInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListStorageCredentialsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListStorageCredentialsResponse) []StorageCredentialInfo { @@ -2142,11 +2216,18 @@ func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.Iterator[stru } func (a *StorageCredentialsAPI) ListAll(ctx context.Context) ([]StorageCredentialInfo, error) { - response, err := a.impl.List(ctx) + var results []StorageCredentialInfo + iter := a.List(ctx) + var err error + var next StorageCredentialInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.StorageCredentials, nil + return results, err } // StorageCredentialInfoNameToIdMap calls [StorageCredentialsAPI.ListAll] and creates a map of results with [StorageCredentialInfo].Name as key and [StorageCredentialInfo].Id as value. @@ -2262,7 +2343,9 @@ func (a *SystemSchemasAPI) Enable(ctx context.Context, request EnableRequest) er // // This method is generated by Databricks SDK Code Generator. func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRequest) *listing.Iterator[ListSystemSchemasRequest, *ListSystemSchemasResponse, SystemSchemaInfo] { + getNextPage := func(ctx context.Context, req ListSystemSchemasRequest) (*ListSystemSchemasResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListSystemSchemasResponse) []SystemSchemaInfo { @@ -2277,11 +2360,18 @@ func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRe } func (a *SystemSchemasAPI) ListAll(ctx context.Context, request ListSystemSchemasRequest) ([]SystemSchemaInfo, error) { - response, err := a.impl.List(ctx, request) + var results []SystemSchemaInfo + iter := a.List(ctx, request) + var err error + var next SystemSchemaInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Schemas, nil + return results, err } // List system schemas. @@ -2476,15 +2566,23 @@ func (a *TablesAPI) GetByFullName(ctx context.Context, fullName string) (*TableI // // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listing.Iterator[ListTablesRequest, *ListTablesResponse, TableInfo] { + getNextPage := func(ctx context.Context, req ListTablesRequest) (*ListTablesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListTablesResponse) []TableInfo { return resp.Tables } - getNextReq := func(resp *ListTablesResponse) ListTablesRequest { + getNextReq := func(resp *ListTablesResponse) (ListTablesRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -2496,30 +2594,22 @@ func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listin func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { var results []TableInfo var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err - } - if len(response.Tables) == 0 { - break - } - for _, v := range response.Tables { - results = append(results, v) - } - count := int(len(response.Tables)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.List(ctx, request) + var err error + var next TableInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // TableInfoNameToTableIdMap calls [TablesAPI.ListAll] and creates a map of results with [TableInfo].Name as key and [TableInfo].TableId as value. @@ -2591,15 +2681,23 @@ func (a *TablesAPI) GetByName(ctx context.Context, name string) (*TableInfo, err // // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequest) *listing.Iterator[ListSummariesRequest, *ListTableSummariesResponse, TableSummary] { + getNextPage := func(ctx context.Context, req ListSummariesRequest) (*ListTableSummariesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListSummaries(ctx, req) } getItems := func(resp *ListTableSummariesResponse) []TableSummary { return resp.Tables } - getNextReq := func(resp *ListTableSummariesResponse) ListSummariesRequest { + getNextReq := func(resp *ListTableSummariesResponse) (ListSummariesRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -2611,30 +2709,22 @@ func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequ func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesRequest) ([]TableSummary, error) { var results []TableSummary var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.ListSummaries(ctx, request) - if err != nil { - return nil, err - } - if len(response.Tables) == 0 { - break - } - for _, v := range response.Tables { - results = append(results, v) - } - count := int(len(response.Tables)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.ListSummaries(ctx, request) + var err error + var next TableSummary + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // Update a table owner. @@ -2748,7 +2838,9 @@ func (a *VolumesAPI) DeleteByFullNameArg(ctx context.Context, fullNameArg string // // This method is generated by Databricks SDK Code Generator. func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *listing.Iterator[ListVolumesRequest, *ListVolumesResponseContent, VolumeInfo] { + getNextPage := func(ctx context.Context, req ListVolumesRequest) (*ListVolumesResponseContent, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListVolumesResponseContent) []VolumeInfo { @@ -2763,11 +2855,18 @@ func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *list } func (a *VolumesAPI) ListAll(ctx context.Context, request ListVolumesRequest) ([]VolumeInfo, error) { - response, err := a.impl.List(ctx, request) + var results []VolumeInfo + iter := a.List(ctx, request) + var err error + var next VolumeInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Volumes, nil + return results, err } // VolumeInfoNameToVolumeIdMap calls [VolumesAPI.ListAll] and creates a map of results with [VolumeInfo].Name as key and [VolumeInfo].VolumeId as value. diff --git a/service/compute/api.go b/service/compute/api.go index 423e3c55f..59af0df19 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -155,7 +155,9 @@ func (a *ClusterPoliciesAPI) GetPermissionsByClusterPolicyId(ctx context.Context // // This method is generated by Databricks SDK Code Generator. func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPoliciesRequest) *listing.Iterator[ListClusterPoliciesRequest, *ListPoliciesResponse, Policy] { + getNextPage := func(ctx context.Context, req ListClusterPoliciesRequest) (*ListPoliciesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListPoliciesResponse) []Policy { @@ -170,11 +172,18 @@ func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPolici } func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request ListClusterPoliciesRequest) ([]Policy, error) { - response, err := a.impl.List(ctx, request) + var results []Policy + iter := a.List(ctx, request) + var err error + var next Policy + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Policies, nil + return results, err } // PolicyNameToPolicyIdMap calls [ClusterPoliciesAPI.ListAll] and creates a map of results with [Policy].Name as key and [Policy].PolicyId as value. @@ -600,15 +609,17 @@ func (a *ClustersAPI) EditAndWait(ctx context.Context, editCluster EditCluster, // // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.Iterator[GetEvents, *GetEventsResponse, ClusterEvent] { + getNextPage := func(ctx context.Context, req GetEvents) (*GetEventsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.Events(ctx, req) } getItems := func(resp *GetEventsResponse) []ClusterEvent { return resp.Events } - getNextReq := func(resp *GetEventsResponse) GetEvents { + getNextReq := func(resp *GetEventsResponse) (GetEvents, listing.ListingStatus) { request = *resp.NextPage - return request + return request, listing.ListingStatusCheckResult } return listing.NewIterator( request, @@ -620,30 +631,22 @@ func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.It func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) { var results []ClusterEvent var totalCount int64 = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.Events(ctx, request) - if err != nil { - return nil, err - } - if len(response.Events) == 0 { - break - } - for _, v := range response.Events { - results = append(results, v) - } - count := int64(len(response.Events)) - totalCount += count - if response.NextPage == nil { - break - } - request = *response.NextPage - limit := request.Limit + limit := request.Limit + iter := a.Events(ctx, request) + var err error + var next ClusterEvent + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // Get cluster info. @@ -712,7 +715,9 @@ func (a *ClustersAPI) GetPermissionsByClusterId(ctx context.Context, clusterId s // // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *listing.Iterator[ListClustersRequest, *ListClustersResponse, ClusterDetails] { + getNextPage := func(ctx context.Context, req ListClustersRequest) (*ListClustersResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListClustersResponse) []ClusterDetails { @@ -727,11 +732,18 @@ func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *li } func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) ([]ClusterDetails, error) { - response, err := a.impl.List(ctx, request) + var results []ClusterDetails + iter := a.List(ctx, request) + var err error + var next ClusterDetails + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Clusters, nil + return results, err } // ClusterDetailsClusterNameToClusterIdMap calls [ClustersAPI.ListAll] and creates a map of results with [ClusterDetails].ClusterName as key and [ClusterDetails].ClusterId as value. @@ -1541,7 +1553,9 @@ func (a *GlobalInitScriptsAPI) GetByScriptId(ctx context.Context, scriptId strin // // This method is generated by Databricks SDK Code Generator. func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListGlobalInitScriptsResponse, GlobalInitScriptDetails] { + getNextPage := func(ctx context.Context, req struct{}) (*ListGlobalInitScriptsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListGlobalInitScriptsResponse) []GlobalInitScriptDetails { @@ -1556,11 +1570,18 @@ func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.Iterator[struc } func (a *GlobalInitScriptsAPI) ListAll(ctx context.Context) ([]GlobalInitScriptDetails, error) { - response, err := a.impl.List(ctx) + var results []GlobalInitScriptDetails + iter := a.List(ctx) + var err error + var next GlobalInitScriptDetails + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Scripts, nil + return results, err } // GlobalInitScriptDetailsNameToScriptIdMap calls [GlobalInitScriptsAPI.ListAll] and creates a map of results with [GlobalInitScriptDetails].Name as key and [GlobalInitScriptDetails].ScriptId as value. @@ -1756,7 +1777,9 @@ func (a *InstancePoolsAPI) GetPermissionsByInstancePoolId(ctx context.Context, i // // This method is generated by Databricks SDK Code Generator. func (a *InstancePoolsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListInstancePools, InstancePoolAndStats] { + getNextPage := func(ctx context.Context, req struct{}) (*ListInstancePools, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListInstancePools) []InstancePoolAndStats { @@ -1771,11 +1794,18 @@ func (a *InstancePoolsAPI) List(ctx context.Context) *listing.Iterator[struct{}, } func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, error) { - response, err := a.impl.List(ctx) + var results []InstancePoolAndStats + iter := a.List(ctx) + var err error + var next InstancePoolAndStats + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.InstancePools, nil + return results, err } // InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap calls [InstancePoolsAPI.ListAll] and creates a map of results with [InstancePoolAndStats].InstancePoolName as key and [InstancePoolAndStats].InstancePoolId as value. @@ -1916,7 +1946,9 @@ func (a *InstanceProfilesAPI) Edit(ctx context.Context, request InstanceProfile) // // This method is generated by Databricks SDK Code Generator. func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListInstanceProfilesResponse, InstanceProfile] { + getNextPage := func(ctx context.Context, req struct{}) (*ListInstanceProfilesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListInstanceProfilesResponse) []InstanceProfile { @@ -1931,11 +1963,18 @@ func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.Iterator[struct } func (a *InstanceProfilesAPI) ListAll(ctx context.Context) ([]InstanceProfile, error) { - response, err := a.impl.List(ctx) + var results []InstanceProfile + iter := a.List(ctx) + var err error + var next InstanceProfile + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.InstanceProfiles, nil + return results, err } // Remove the instance profile. @@ -2036,7 +2075,9 @@ func (a *LibrariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterL // // This method is generated by Databricks SDK Code Generator. func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) *listing.Iterator[ClusterStatusRequest, *ClusterLibraryStatuses, LibraryFullStatus] { + getNextPage := func(ctx context.Context, req ClusterStatusRequest) (*ClusterLibraryStatuses, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ClusterStatus(ctx, req) } getItems := func(resp *ClusterLibraryStatuses) []LibraryFullStatus { @@ -2051,11 +2092,18 @@ func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusR } func (a *LibrariesAPI) ClusterStatusAll(ctx context.Context, request ClusterStatusRequest) ([]LibraryFullStatus, error) { - response, err := a.impl.ClusterStatus(ctx, request) + var results []LibraryFullStatus + iter := a.ClusterStatus(ctx, request) + var err error + var next LibraryFullStatus + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.LibraryStatuses, nil + return results, err } // Get status. @@ -2159,15 +2207,23 @@ func (a *PolicyFamiliesAPI) GetByPolicyFamilyId(ctx context.Context, policyFamil // // This method is generated by Databricks SDK Code Generator. func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamiliesRequest) *listing.Iterator[ListPolicyFamiliesRequest, *ListPolicyFamiliesResponse, PolicyFamily] { + getNextPage := func(ctx context.Context, req ListPolicyFamiliesRequest) (*ListPolicyFamiliesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListPolicyFamiliesResponse) []PolicyFamily { return resp.PolicyFamilies } - getNextReq := func(resp *ListPolicyFamiliesResponse) ListPolicyFamiliesRequest { + getNextReq := func(resp *ListPolicyFamiliesResponse) (ListPolicyFamiliesRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -2179,28 +2235,20 @@ func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamilies func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamiliesRequest) ([]PolicyFamily, error) { var results []PolicyFamily var totalCount int64 = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err - } - if len(response.PolicyFamilies) == 0 { - break - } - for _, v := range response.PolicyFamilies { - results = append(results, v) - } - count := int64(len(response.PolicyFamilies)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.List(ctx, request) + var err error + var next PolicyFamily + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } diff --git a/service/files/api.go b/service/files/api.go index 837e959f2..af566f738 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/databricks-sdk-go/client" "github.com/databricks/databricks-sdk-go/listing" + "github.com/databricks/databricks-sdk-go/useragent" ) func NewDbfs(client *client.DatabricksClient) *DbfsAPI { @@ -142,7 +143,9 @@ func (a *DbfsAPI) GetStatusByPath(ctx context.Context, path string) (*FileInfo, // // This method is generated by Databricks SDK Code Generator. func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.Iterator[ListDbfsRequest, *ListStatusResponse, FileInfo] { + getNextPage := func(ctx context.Context, req ListDbfsRequest) (*ListStatusResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListStatusResponse) []FileInfo { @@ -157,11 +160,18 @@ func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.It } func (a *DbfsAPI) ListAll(ctx context.Context, request ListDbfsRequest) ([]FileInfo, error) { - response, err := a.impl.List(ctx, request) + var results []FileInfo + iter := a.List(ctx, request) + var err error + var next FileInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Files, nil + return results, err } // List directory contents or file details. diff --git a/service/iam/api.go b/service/iam/api.go index c811b4e16..597d7c043 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -204,7 +204,9 @@ func (a *AccountGroupsAPI) GetById(ctx context.Context, id string) (*Group, erro // // This method is generated by Databricks SDK Code Generator. func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRequest) *listing.Iterator[ListAccountGroupsRequest, *ListGroupsResponse, Group] { + getNextPage := func(ctx context.Context, req ListAccountGroupsRequest) (*ListGroupsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListGroupsResponse) []Group { @@ -219,11 +221,18 @@ func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRe } func (a *AccountGroupsAPI) ListAll(ctx context.Context, request ListAccountGroupsRequest) ([]Group, error) { - response, err := a.impl.List(ctx, request) + var results []Group + iter := a.List(ctx, request) + var err error + var next Group + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Resources, nil + return results, err } // GroupDisplayNameToIdMap calls [AccountGroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -372,7 +381,9 @@ func (a *AccountServicePrincipalsAPI) GetById(ctx context.Context, id string) (* // // This method is generated by Databricks SDK Code Generator. func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAccountServicePrincipalsRequest) *listing.Iterator[ListAccountServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { + getNextPage := func(ctx context.Context, req ListAccountServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListServicePrincipalResponse) []ServicePrincipal { @@ -387,11 +398,18 @@ func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAcco } func (a *AccountServicePrincipalsAPI) ListAll(ctx context.Context, request ListAccountServicePrincipalsRequest) ([]ServicePrincipal, error) { - response, err := a.impl.List(ctx, request) + var results []ServicePrincipal + iter := a.List(ctx, request) + var err error + var next ServicePrincipal + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Resources, nil + return results, err } // ServicePrincipalDisplayNameToIdMap calls [AccountServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -549,7 +567,9 @@ func (a *AccountUsersAPI) GetById(ctx context.Context, id string) (*User, error) // // This method is generated by Databricks SDK Code Generator. func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequest) *listing.Iterator[ListAccountUsersRequest, *ListUsersResponse, User] { + getNextPage := func(ctx context.Context, req ListAccountUsersRequest) (*ListUsersResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListUsersResponse) []User { @@ -564,11 +584,18 @@ func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequ } func (a *AccountUsersAPI) ListAll(ctx context.Context, request ListAccountUsersRequest) ([]User, error) { - response, err := a.impl.List(ctx, request) + var results []User + iter := a.List(ctx, request) + var err error + var next User + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Resources, nil + return results, err } // UserUserNameToIdMap calls [AccountUsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -753,7 +780,9 @@ func (a *GroupsAPI) GetById(ctx context.Context, id string) (*Group, error) { // // This method is generated by Databricks SDK Code Generator. func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listing.Iterator[ListGroupsRequest, *ListGroupsResponse, Group] { + getNextPage := func(ctx context.Context, req ListGroupsRequest) (*ListGroupsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListGroupsResponse) []Group { @@ -768,11 +797,18 @@ func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listin } func (a *GroupsAPI) ListAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { - response, err := a.impl.List(ctx, request) + var results []Group + iter := a.List(ctx, request) + var err error + var next Group + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Resources, nil + return results, err } // GroupDisplayNameToIdMap calls [GroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -1046,7 +1082,9 @@ func (a *ServicePrincipalsAPI) GetById(ctx context.Context, id string) (*Service // // This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrincipalsRequest) *listing.Iterator[ListServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { + getNextPage := func(ctx context.Context, req ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListServicePrincipalResponse) []ServicePrincipal { @@ -1061,11 +1099,18 @@ func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrin } func (a *ServicePrincipalsAPI) ListAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { - response, err := a.impl.List(ctx, request) + var results []ServicePrincipal + iter := a.List(ctx, request) + var err error + var next ServicePrincipal + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Resources, nil + return results, err } // ServicePrincipalDisplayNameToIdMap calls [ServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -1238,7 +1283,9 @@ func (a *UsersAPI) GetPermissions(ctx context.Context) (*PasswordPermissions, er // // This method is generated by Databricks SDK Code Generator. func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing.Iterator[ListUsersRequest, *ListUsersResponse, User] { + getNextPage := func(ctx context.Context, req ListUsersRequest) (*ListUsersResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListUsersResponse) []User { @@ -1253,11 +1300,18 @@ func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing. } func (a *UsersAPI) ListAll(ctx context.Context, request ListUsersRequest) ([]User, error) { - response, err := a.impl.List(ctx, request) + var results []User + iter := a.List(ctx, request) + var err error + var next User + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Resources, nil + return results, err } // UserUserNameToIdMap calls [UsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -1416,7 +1470,9 @@ func (a *WorkspaceAssignmentAPI) GetByWorkspaceId(ctx context.Context, workspace // // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspaceAssignmentRequest) *listing.Iterator[ListWorkspaceAssignmentRequest, *PermissionAssignments, PermissionAssignment] { + getNextPage := func(ctx context.Context, req ListWorkspaceAssignmentRequest) (*PermissionAssignments, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *PermissionAssignments) []PermissionAssignment { @@ -1431,11 +1487,18 @@ func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspace } func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorkspaceAssignmentRequest) ([]PermissionAssignment, error) { - response, err := a.impl.List(ctx, request) + var results []PermissionAssignment + iter := a.List(ctx, request) + var err error + var next PermissionAssignment + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.PermissionAssignments, nil + return results, err } // Get permission assignments. diff --git a/service/iam/model.go b/service/iam/model.go index 8a1ba4cd1..f13094f41 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,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. diff --git a/service/jobs/api.go b/service/jobs/api.go index f73df8b95..912aecb8b 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -329,15 +329,23 @@ func (a *JobsAPI) GetRunOutputByRunId(ctx context.Context, runId int64) (*RunOut // // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.Iterator[ListJobsRequest, *ListJobsResponse, BaseJob] { + getNextPage := func(ctx context.Context, req ListJobsRequest) (*ListJobsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListJobsResponse) []BaseJob { return resp.Jobs } - getNextReq := func(resp *ListJobsResponse) ListJobsRequest { + getNextReq := func(resp *ListJobsResponse) (ListJobsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -349,30 +357,22 @@ func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.It func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJob, error) { var results []BaseJob var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err - } - if len(response.Jobs) == 0 { - break - } - for _, v := range response.Jobs { - results = append(results, v) - } - count := int(len(response.Jobs)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.Limit + limit := request.Limit + iter := a.List(ctx, request) + var err error + var next BaseJob + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // BaseJobSettingsNameToJobIdMap calls [JobsAPI.ListAll] and creates a map of results with [BaseJob].Settings.Name as key and [BaseJob].JobId as value. @@ -434,15 +434,23 @@ func (a *JobsAPI) GetBySettingsName(ctx context.Context, name string) (*BaseJob, // // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listing.Iterator[ListRunsRequest, *ListRunsResponse, BaseRun] { + getNextPage := func(ctx context.Context, req ListRunsRequest) (*ListRunsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListRuns(ctx, req) } getItems := func(resp *ListRunsResponse) []BaseRun { return resp.Runs } - getNextReq := func(resp *ListRunsResponse) ListRunsRequest { + getNextReq := func(resp *ListRunsResponse) (ListRunsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -454,30 +462,22 @@ func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listin func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]BaseRun, error) { var results []BaseRun var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.ListRuns(ctx, request) - if err != nil { - return nil, err - } - if len(response.Runs) == 0 { - break - } - for _, v := range response.Runs { - results = append(results, v) - } - count := int(len(response.Runs)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.Limit + limit := request.Limit + iter := a.ListRuns(ctx, request) + var err error + var next BaseRun + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // Repair a job run. diff --git a/service/ml/api.go b/service/ml/api.go index 6abb0d131..996a5ec8e 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -128,15 +128,23 @@ func (a *ExperimentsAPI) GetExperiment(ctx context.Context, request GetExperimen // // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) *listing.Iterator[GetHistoryRequest, *GetMetricHistoryResponse, Metric] { + getNextPage := func(ctx context.Context, req GetHistoryRequest) (*GetMetricHistoryResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.GetHistory(ctx, req) } getItems := func(resp *GetMetricHistoryResponse) []Metric { return resp.Metrics } - getNextReq := func(resp *GetMetricHistoryResponse) GetHistoryRequest { + getNextReq := func(resp *GetMetricHistoryResponse) (GetHistoryRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -148,30 +156,22 @@ func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryReque func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRequest) ([]Metric, error) { var results []Metric var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.GetHistory(ctx, request) - if err != nil { - return nil, err - } - if len(response.Metrics) == 0 { - break - } - for _, v := range response.Metrics { - results = append(results, v) - } - count := int(len(response.Metrics)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.GetHistory(ctx, request) + var err error + var next Metric + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // Get experiment permission levels. @@ -227,15 +227,23 @@ func (a *ExperimentsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Ge // // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifactsRequest) *listing.Iterator[ListArtifactsRequest, *ListArtifactsResponse, FileInfo] { + getNextPage := func(ctx context.Context, req ListArtifactsRequest) (*ListArtifactsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListArtifacts(ctx, req) } getItems := func(resp *ListArtifactsResponse) []FileInfo { return resp.Files } - getNextReq := func(resp *ListArtifactsResponse) ListArtifactsRequest { + getNextReq := func(resp *ListArtifactsResponse) (ListArtifactsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -246,24 +254,17 @@ func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifact func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) { var results []FileInfo - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.ListArtifacts(ctx, request) - if err != nil { - return nil, err - } - if len(response.Files) == 0 { - break - } - for _, v := range response.Files { - results = append(results, v) - } - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } + iter := a.ListArtifacts(ctx, request) + var err error + var next FileInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } + if err != nil { + return nil, err } - return results, nil + return results, err } // List experiments. @@ -272,15 +273,23 @@ func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtif // // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperimentsRequest) *listing.Iterator[ListExperimentsRequest, *ListExperimentsResponse, Experiment] { + getNextPage := func(ctx context.Context, req ListExperimentsRequest) (*ListExperimentsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListExperiments(ctx, req) } getItems := func(resp *ListExperimentsResponse) []Experiment { return resp.Experiments } - getNextReq := func(resp *ListExperimentsResponse) ListExperimentsRequest { + getNextReq := func(resp *ListExperimentsResponse) (ListExperimentsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -292,30 +301,22 @@ func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperi func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) { var results []Experiment var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.ListExperiments(ctx, request) - if err != nil { - return nil, err - } - if len(response.Experiments) == 0 { - break - } - for _, v := range response.Experiments { - results = append(results, v) - } - count := int(len(response.Experiments)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.ListExperiments(ctx, request) + var err error + var next Experiment + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // Log a batch. @@ -429,15 +430,23 @@ func (a *ExperimentsAPI) RestoreRuns(ctx context.Context, request RestoreRuns) ( // // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchExperiments) *listing.Iterator[SearchExperiments, *SearchExperimentsResponse, Experiment] { + getNextPage := func(ctx context.Context, req SearchExperiments) (*SearchExperimentsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.SearchExperiments(ctx, req) } getItems := func(resp *SearchExperimentsResponse) []Experiment { return resp.Experiments } - getNextReq := func(resp *SearchExperimentsResponse) SearchExperiments { + getNextReq := func(resp *SearchExperimentsResponse) (SearchExperiments, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -448,24 +457,17 @@ func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchEx func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) { var results []Experiment - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.SearchExperiments(ctx, request) - if err != nil { - return nil, err - } - if len(response.Experiments) == 0 { - break - } - for _, v := range response.Experiments { - results = append(results, v) - } - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } + iter := a.SearchExperiments(ctx, request) + var err error + var next Experiment + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } + if err != nil { + return nil, err } - return results, nil + return results, err } // Search for runs. @@ -476,15 +478,23 @@ func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request Searc // // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *listing.Iterator[SearchRuns, *SearchRunsResponse, Run] { + getNextPage := func(ctx context.Context, req SearchRuns) (*SearchRunsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.SearchRuns(ctx, req) } getItems := func(resp *SearchRunsResponse) []Run { return resp.Runs } - getNextReq := func(resp *SearchRunsResponse) SearchRuns { + getNextReq := func(resp *SearchRunsResponse) (SearchRuns, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -495,24 +505,17 @@ func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *li func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) ([]Run, error) { var results []Run - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.SearchRuns(ctx, request) - if err != nil { - return nil, err - } - if len(response.Runs) == 0 { - break - } - for _, v := range response.Runs { - results = append(results, v) - } - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } + iter := a.SearchRuns(ctx, request) + var err error + var next Run + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) } - return results, nil + if err != nil { + return nil, err + } + return results, err } // Set a tag. @@ -695,7 +698,9 @@ func (a *ModelRegistryAPI) DeleteWebhook(ctx context.Context, request DeleteWebh // // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) *listing.Iterator[GetLatestVersionsRequest, *GetLatestVersionsResponse, ModelVersion] { + getNextPage := func(ctx context.Context, req GetLatestVersionsRequest) (*GetLatestVersionsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.GetLatestVersions(ctx, req) } getItems := func(resp *GetLatestVersionsResponse) []ModelVersion { @@ -710,11 +715,18 @@ func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLat } func (a *ModelRegistryAPI) GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) { - response, err := a.impl.GetLatestVersions(ctx, request) + var results []ModelVersion + iter := a.GetLatestVersions(ctx, request) + var err error + var next ModelVersion + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.ModelVersions, nil + return results, err } // Get model. @@ -783,15 +795,23 @@ func (a *ModelRegistryAPI) GetPermissionsByRegisteredModelId(ctx context.Context // // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsRequest) *listing.Iterator[ListModelsRequest, *ListModelsResponse, Model] { + getNextPage := func(ctx context.Context, req ListModelsRequest) (*ListModelsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListModels(ctx, req) } getItems := func(resp *ListModelsResponse) []Model { return resp.RegisteredModels } - getNextReq := func(resp *ListModelsResponse) ListModelsRequest { + getNextReq := func(resp *ListModelsResponse) (ListModelsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -803,30 +823,22 @@ func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsReq func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModelsRequest) ([]Model, error) { var results []Model var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.ListModels(ctx, request) - if err != nil { - return nil, err - } - if len(response.RegisteredModels) == 0 { - break - } - for _, v := range response.RegisteredModels { - results = append(results, v) - } - count := int(len(response.RegisteredModels)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.ListModels(ctx, request) + var err error + var next Model + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // List transition requests. @@ -835,7 +847,9 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels // // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request ListTransitionRequestsRequest) *listing.Iterator[ListTransitionRequestsRequest, *ListTransitionRequestsResponse, Activity] { + getNextPage := func(ctx context.Context, req ListTransitionRequestsRequest) (*ListTransitionRequestsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListTransitionRequests(ctx, req) } getItems := func(resp *ListTransitionRequestsResponse) []Activity { @@ -850,11 +864,18 @@ func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request L } func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, request ListTransitionRequestsRequest) ([]Activity, error) { - response, err := a.impl.ListTransitionRequests(ctx, request) + var results []Activity + iter := a.ListTransitionRequests(ctx, request) + var err error + var next Activity + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Requests, nil + return results, err } // List registry webhooks. @@ -865,15 +886,23 @@ func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, reques // // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhooksRequest) *listing.Iterator[ListWebhooksRequest, *ListRegistryWebhooks, RegistryWebhook] { + getNextPage := func(ctx context.Context, req ListWebhooksRequest) (*ListRegistryWebhooks, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListWebhooks(ctx, req) } getItems := func(resp *ListRegistryWebhooks) []RegistryWebhook { return resp.Webhooks } - getNextReq := func(resp *ListRegistryWebhooks) ListWebhooksRequest { + getNextReq := func(resp *ListRegistryWebhooks) (ListWebhooksRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -884,24 +913,17 @@ func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhook func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebhooksRequest) ([]RegistryWebhook, error) { var results []RegistryWebhook - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.ListWebhooks(ctx, request) - if err != nil { - return nil, err - } - if len(response.Webhooks) == 0 { - break - } - for _, v := range response.Webhooks { - results = append(results, v) - } - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } + iter := a.ListWebhooks(ctx, request) + var err error + var next RegistryWebhook + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) } - return results, nil + if err != nil { + return nil, err + } + return results, err } // Reject a transition request. @@ -924,15 +946,23 @@ func (a *ModelRegistryAPI) RenameModel(ctx context.Context, request RenameModelR // // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request SearchModelVersionsRequest) *listing.Iterator[SearchModelVersionsRequest, *SearchModelVersionsResponse, ModelVersion] { + getNextPage := func(ctx context.Context, req SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.SearchModelVersions(ctx, req) } getItems := func(resp *SearchModelVersionsResponse) []ModelVersion { return resp.ModelVersions } - getNextReq := func(resp *SearchModelVersionsResponse) SearchModelVersionsRequest { + getNextReq := func(resp *SearchModelVersionsResponse) (SearchModelVersionsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -944,30 +974,22 @@ func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request Sear func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) { var results []ModelVersion var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.SearchModelVersions(ctx, request) - if err != nil { - return nil, err - } - if len(response.ModelVersions) == 0 { - break - } - for _, v := range response.ModelVersions { - results = append(results, v) - } - count := int(len(response.ModelVersions)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.SearchModelVersions(ctx, request) + var err error + var next ModelVersion + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // Search models. @@ -976,15 +998,23 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S // // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModelsRequest) *listing.Iterator[SearchModelsRequest, *SearchModelsResponse, Model] { + getNextPage := func(ctx context.Context, req SearchModelsRequest) (*SearchModelsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.SearchModels(ctx, req) } getItems := func(resp *SearchModelsResponse) []Model { return resp.RegisteredModels } - getNextReq := func(resp *SearchModelsResponse) SearchModelsRequest { + getNextReq := func(resp *SearchModelsResponse) (SearchModelsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -996,30 +1026,22 @@ func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModel func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchModelsRequest) ([]Model, error) { var results []Model var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.SearchModels(ctx, request) - if err != nil { - return nil, err - } - if len(response.RegisteredModels) == 0 { - break - } - for _, v := range response.RegisteredModels { - results = append(results, v) - } - count := int(len(response.RegisteredModels)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.SearchModels(ctx, request) + var err error + var next Model + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // Set a tag. diff --git a/service/oauth2/api.go b/service/oauth2/api.go index dc3938bde..43be91dc1 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -91,7 +91,9 @@ func (a *CustomAppIntegrationAPI) GetByIntegrationId(ctx context.Context, integr // // This method is generated by Databricks SDK Code Generator. func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetCustomAppIntegrationsOutput, GetCustomAppIntegrationOutput] { + getNextPage := func(ctx context.Context, req struct{}) (*GetCustomAppIntegrationsOutput, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *GetCustomAppIntegrationsOutput) []GetCustomAppIntegrationOutput { @@ -106,11 +108,18 @@ func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[st } func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIntegrationOutput, error) { - response, err := a.impl.List(ctx) + var results []GetCustomAppIntegrationOutput + iter := a.List(ctx) + var err error + var next GetCustomAppIntegrationOutput + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Apps, nil + return results, err } // Updates Custom OAuth App Integration. @@ -213,15 +222,23 @@ func (a *OAuthPublishedAppsAPI) Impl() OAuthPublishedAppsService { // // This method is generated by Databricks SDK Code Generator. func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPublishedAppsRequest) *listing.Iterator[ListOAuthPublishedAppsRequest, *GetPublishedAppsOutput, PublishedAppOutput] { + getNextPage := func(ctx context.Context, req ListOAuthPublishedAppsRequest) (*GetPublishedAppsOutput, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *GetPublishedAppsOutput) []PublishedAppOutput { return resp.Apps } - getNextReq := func(resp *GetPublishedAppsOutput) ListOAuthPublishedAppsRequest { + getNextReq := func(resp *GetPublishedAppsOutput) (ListOAuthPublishedAppsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -233,30 +250,22 @@ func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPubli func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPublishedAppsRequest) ([]PublishedAppOutput, error) { var results []PublishedAppOutput var totalCount int64 = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err - } - if len(response.Apps) == 0 { - break - } - for _, v := range response.Apps { - results = append(results, v) - } - count := int64(len(response.Apps)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.PageSize + limit := request.PageSize + iter := a.List(ctx, request) + var err error + var next PublishedAppOutput + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } func NewPublishedAppIntegration(client *client.DatabricksClient) *PublishedAppIntegrationAPI { @@ -339,7 +348,9 @@ func (a *PublishedAppIntegrationAPI) GetByIntegrationId(ctx context.Context, int // // This method is generated by Databricks SDK Code Generator. func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetPublishedAppIntegrationsOutput, GetPublishedAppIntegrationOutput] { + getNextPage := func(ctx context.Context, req struct{}) (*GetPublishedAppIntegrationsOutput, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *GetPublishedAppIntegrationsOutput) []GetPublishedAppIntegrationOutput { @@ -354,11 +365,18 @@ func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.Iterator } func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishedAppIntegrationOutput, error) { - response, err := a.impl.List(ctx) + var results []GetPublishedAppIntegrationOutput + iter := a.List(ctx) + var err error + var next GetPublishedAppIntegrationOutput + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Apps, nil + return results, err } // Updates Published OAuth App Integration. @@ -440,7 +458,9 @@ func (a *ServicePrincipalSecretsAPI) DeleteByServicePrincipalIdAndSecretId(ctx c // // This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServicePrincipalSecretsRequest) *listing.Iterator[ListServicePrincipalSecretsRequest, *ListServicePrincipalSecretsResponse, SecretInfo] { + getNextPage := func(ctx context.Context, req ListServicePrincipalSecretsRequest) (*ListServicePrincipalSecretsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListServicePrincipalSecretsResponse) []SecretInfo { @@ -455,11 +475,18 @@ func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServi } func (a *ServicePrincipalSecretsAPI) ListAll(ctx context.Context, request ListServicePrincipalSecretsRequest) ([]SecretInfo, error) { - response, err := a.impl.List(ctx, request) + var results []SecretInfo + iter := a.List(ctx, request) + var err error + var next SecretInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Secrets, nil + return results, err } // List service principal secrets. diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 0bb318f16..733463c92 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -255,15 +255,23 @@ func (a *PipelinesAPI) GetUpdateByPipelineIdAndUpdateId(ctx context.Context, pip // // This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipelineEventsRequest) *listing.Iterator[ListPipelineEventsRequest, *ListPipelineEventsResponse, PipelineEvent] { + getNextPage := func(ctx context.Context, req ListPipelineEventsRequest) (*ListPipelineEventsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListPipelineEvents(ctx, req) } getItems := func(resp *ListPipelineEventsResponse) []PipelineEvent { return resp.Events } - getNextReq := func(resp *ListPipelineEventsResponse) ListPipelineEventsRequest { + getNextReq := func(resp *ListPipelineEventsResponse) (ListPipelineEventsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -275,30 +283,22 @@ func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipel func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPipelineEventsRequest) ([]PipelineEvent, error) { var results []PipelineEvent var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.ListPipelineEvents(ctx, request) - if err != nil { - return nil, err - } - if len(response.Events) == 0 { - break - } - for _, v := range response.Events { - results = append(results, v) - } - count := int(len(response.Events)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.ListPipelineEvents(ctx, request) + var err error + var next PipelineEvent + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // List pipeline events. @@ -316,15 +316,23 @@ func (a *PipelinesAPI) ListPipelineEventsByPipelineId(ctx context.Context, pipel // // This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesRequest) *listing.Iterator[ListPipelinesRequest, *ListPipelinesResponse, PipelineStateInfo] { + getNextPage := func(ctx context.Context, req ListPipelinesRequest) (*ListPipelinesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListPipelines(ctx, req) } getItems := func(resp *ListPipelinesResponse) []PipelineStateInfo { return resp.Statuses } - getNextReq := func(resp *ListPipelinesResponse) ListPipelinesRequest { + getNextReq := func(resp *ListPipelinesResponse) (ListPipelinesRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -336,30 +344,22 @@ func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesR func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelinesRequest) ([]PipelineStateInfo, error) { var results []PipelineStateInfo var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.ListPipelines(ctx, request) - if err != nil { - return nil, err - } - if len(response.Statuses) == 0 { - break - } - for _, v := range response.Statuses { - results = append(results, v) - } - count := int(len(response.Statuses)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.ListPipelines(ctx, request) + var err error + var next PipelineStateInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // PipelineStateInfoNameToPipelineIdMap calls [PipelinesAPI.ListPipelinesAll] and creates a map of results with [PipelineStateInfo].Name as key and [PipelineStateInfo].PipelineId as value. diff --git a/service/serving/api.go b/service/serving/api.go index ec5aeb7eb..04f2ba178 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -254,7 +254,9 @@ func (a *ServingEndpointsAPI) GetPermissionsByServingEndpointId(ctx context.Cont // // This method is generated by Databricks SDK Code Generator. func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListEndpointsResponse, ServingEndpoint] { + getNextPage := func(ctx context.Context, req struct{}) (*ListEndpointsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListEndpointsResponse) []ServingEndpoint { @@ -269,11 +271,18 @@ func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.Iterator[struct } func (a *ServingEndpointsAPI) ListAll(ctx context.Context) ([]ServingEndpoint, error) { - response, err := a.impl.List(ctx) + var results []ServingEndpoint + iter := a.List(ctx) + var err error + var next ServingEndpoint + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Endpoints, nil + return results, err } // Retrieve the most recent log lines associated with a given serving endpoint's diff --git a/service/settings/api.go b/service/settings/api.go index cc5564121..5fe7031d8 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -118,7 +118,9 @@ func (a *AccountIpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAcc // // This method is generated by Databricks SDK Code Generator. func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetIpAccessListsResponse, IpAccessListInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*GetIpAccessListsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *GetIpAccessListsResponse) []IpAccessListInfo { @@ -133,11 +135,18 @@ func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.Iterator[st } func (a *AccountIpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { - response, err := a.impl.List(ctx) + var results []IpAccessListInfo + iter := a.List(ctx) + var err error + var next IpAccessListInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.IpAccessLists, nil + return results, err } // IpAccessListInfoLabelToListIdMap calls [AccountIpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -429,7 +438,9 @@ func (a *IpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAccessList // // This method is generated by Databricks SDK Code Generator. func (a *IpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListIpAccessListResponse, IpAccessListInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListIpAccessListResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListIpAccessListResponse) []IpAccessListInfo { @@ -444,11 +455,18 @@ func (a *IpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, } func (a *IpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { - response, err := a.impl.List(ctx) + var results []IpAccessListInfo + iter := a.List(ctx) + var err error + var next IpAccessListInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.IpAccessLists, nil + return results, err } // IpAccessListInfoLabelToListIdMap calls [IpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -686,7 +704,9 @@ func (a *TokenManagementAPI) GetPermissions(ctx context.Context) (*TokenPermissi // // This method is generated by Databricks SDK Code Generator. func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManagementRequest) *listing.Iterator[ListTokenManagementRequest, *ListTokensResponse, TokenInfo] { + getNextPage := func(ctx context.Context, req ListTokenManagementRequest) (*ListTokensResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListTokensResponse) []TokenInfo { @@ -701,11 +721,18 @@ func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManageme } func (a *TokenManagementAPI) ListAll(ctx context.Context, request ListTokenManagementRequest) ([]TokenInfo, error) { - response, err := a.impl.List(ctx, request) + var results []TokenInfo + iter := a.List(ctx, request) + var err error + var next TokenInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.TokenInfos, nil + return results, err } // TokenInfoCommentToTokenIdMap calls [TokenManagementAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. @@ -843,7 +870,9 @@ func (a *TokensAPI) DeleteByTokenId(ctx context.Context, tokenId string) error { // // This method is generated by Databricks SDK Code Generator. func (a *TokensAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListTokensResponse, TokenInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListTokensResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListTokensResponse) []TokenInfo { @@ -858,11 +887,18 @@ func (a *TokensAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListT } func (a *TokensAPI) ListAll(ctx context.Context) ([]TokenInfo, error) { - response, err := a.impl.List(ctx) + var results []TokenInfo + iter := a.List(ctx) + var err error + var next TokenInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.TokenInfos, nil + return results, err } // TokenInfoCommentToTokenIdMap calls [TokensAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. diff --git a/service/sharing/api.go b/service/sharing/api.go index ea9133e2d..2fb450726 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -97,15 +97,23 @@ func (a *CleanRoomsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Clea // // This method is generated by Databricks SDK Code Generator. func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) *listing.Iterator[ListCleanRoomsRequest, *ListCleanRoomsResponse, CleanRoomInfo] { + getNextPage := func(ctx context.Context, req ListCleanRoomsRequest) (*ListCleanRoomsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListCleanRoomsResponse) []CleanRoomInfo { return resp.CleanRooms } - getNextReq := func(resp *ListCleanRoomsResponse) ListCleanRoomsRequest { + getNextReq := func(resp *ListCleanRoomsResponse) (ListCleanRoomsRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -117,30 +125,22 @@ func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsRequest) ([]CleanRoomInfo, error) { var results []CleanRoomInfo var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err - } - if len(response.CleanRooms) == 0 { - break - } - for _, v := range response.CleanRooms { - results = append(results, v) - } - count := int(len(response.CleanRooms)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.List(ctx, request) + var err error + var next CleanRoomInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // Update a clean room. @@ -248,7 +248,9 @@ func (a *ProvidersAPI) GetByName(ctx context.Context, name string) (*ProviderInf // // This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) *listing.Iterator[ListProvidersRequest, *ListProvidersResponse, ProviderInfo] { + getNextPage := func(ctx context.Context, req ListProvidersRequest) (*ListProvidersResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListProvidersResponse) []ProviderInfo { @@ -263,11 +265,18 @@ func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) * } func (a *ProvidersAPI) ListAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) { - response, err := a.impl.List(ctx, request) + var results []ProviderInfo + iter := a.List(ctx, request) + var err error + var next ProviderInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Providers, nil + return results, err } // ProviderInfoNameToMetastoreIdMap calls [ProvidersAPI.ListAll] and creates a map of results with [ProviderInfo].Name as key and [ProviderInfo].MetastoreId as value. @@ -303,7 +312,9 @@ func (a *ProvidersAPI) ProviderInfoNameToMetastoreIdMap(ctx context.Context, req // // This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest) *listing.Iterator[ListSharesRequest, *ListProviderSharesResponse, ProviderShare] { + getNextPage := func(ctx context.Context, req ListSharesRequest) (*ListProviderSharesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListShares(ctx, req) } getItems := func(resp *ListProviderSharesResponse) []ProviderShare { @@ -318,11 +329,18 @@ func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest } func (a *ProvidersAPI) ListSharesAll(ctx context.Context, request ListSharesRequest) ([]ProviderShare, error) { - response, err := a.impl.ListShares(ctx, request) + var results []ProviderShare + iter := a.ListShares(ctx, request) + var err error + var next ProviderShare + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Shares, nil + return results, err } // List shares by Provider. @@ -515,7 +533,9 @@ func (a *RecipientsAPI) GetByName(ctx context.Context, name string) (*RecipientI // // This method is generated by Databricks SDK Code Generator. func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) *listing.Iterator[ListRecipientsRequest, *ListRecipientsResponse, RecipientInfo] { + getNextPage := func(ctx context.Context, req ListRecipientsRequest) (*ListRecipientsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListRecipientsResponse) []RecipientInfo { @@ -530,11 +550,18 @@ func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) } func (a *RecipientsAPI) ListAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) { - response, err := a.impl.List(ctx, request) + var results []RecipientInfo + iter := a.List(ctx, request) + var err error + var next RecipientInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Recipients, nil + return results, err } // RecipientInfoNameToMetastoreIdMap calls [RecipientsAPI.ListAll] and creates a map of results with [RecipientInfo].Name as key and [RecipientInfo].MetastoreId as value. @@ -682,7 +709,9 @@ func (a *SharesAPI) GetByName(ctx context.Context, name string) (*ShareInfo, err // // This method is generated by Databricks SDK Code Generator. func (a *SharesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListSharesResponse, ShareInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*ListSharesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *ListSharesResponse) []ShareInfo { @@ -697,11 +726,18 @@ func (a *SharesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListS } func (a *SharesAPI) ListAll(ctx context.Context) ([]ShareInfo, error) { - response, err := a.impl.List(ctx) + var results []ShareInfo + iter := a.List(ctx) + var err error + var next ShareInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Shares, nil + return results, err } // Get permissions. diff --git a/service/sql/api.go b/service/sql/api.go index d7222bd19..669790e00 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -287,15 +287,18 @@ func (a *DashboardsAPI) GetByDashboardId(ctx context.Context, dashboardId string // // This method is generated by Databricks SDK Code Generator. func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) *listing.Iterator[ListDashboardsRequest, *ListResponse, Dashboard] { + request.Page = 1 // start iterating from the first page + getNextPage := func(ctx context.Context, req ListDashboardsRequest) (*ListResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListResponse) []Dashboard { return resp.Results } - getNextReq := func(resp *ListResponse) ListDashboardsRequest { + getNextReq := func(resp *ListResponse) (ListDashboardsRequest, listing.ListingStatus) { request.Page = resp.Page + 1 - return request + return request, listing.ListingStatusCheckResult } return listing.NewIterator( request, @@ -307,36 +310,29 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { var results []Dashboard var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") + limit := request.PageSize + iter := a.List(ctx, request) // deduplicate items that may have been added during iteration seen := map[string]bool{} - request.Page = 1 // start iterating from the first page - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err + var err error + var next Dashboard + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + id := next.Id + if seen[id] { + // item was added during iteration + continue } - if len(response.Results) == 0 { - break - } - for _, v := range response.Results { - id := v.Id - if seen[id] { - // item was added during iteration - continue - } - seen[id] = true - results = append(results, v) - } - count := int(len(response.Results)) - totalCount += count - request.Page++ - limit := request.PageSize + seen[id] = true + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // DashboardNameToIdMap calls [DashboardsAPI.ListAll] and creates a map of results with [Dashboard].Name as key and [Dashboard].Id as value. @@ -661,15 +657,18 @@ func (a *QueriesAPI) GetByQueryId(ctx context.Context, queryId string) (*Query, // // This method is generated by Databricks SDK Code Generator. func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *listing.Iterator[ListQueriesRequest, *QueryList, Query] { + request.Page = 1 // start iterating from the first page + getNextPage := func(ctx context.Context, req ListQueriesRequest) (*QueryList, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *QueryList) []Query { return resp.Results } - getNextReq := func(resp *QueryList) ListQueriesRequest { + getNextReq := func(resp *QueryList) (ListQueriesRequest, listing.ListingStatus) { request.Page = resp.Page + 1 - return request + return request, listing.ListingStatusCheckResult } return listing.NewIterator( request, @@ -681,36 +680,29 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *list func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { var results []Query var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") + limit := request.PageSize + iter := a.List(ctx, request) // deduplicate items that may have been added during iteration seen := map[string]bool{} - request.Page = 1 // start iterating from the first page - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err + var err error + var next Query + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + id := next.Id + if seen[id] { + // item was added during iteration + continue } - if len(response.Results) == 0 { - break - } - for _, v := range response.Results { - id := v.Id - if seen[id] { - // item was added during iteration - continue - } - seen[id] = true - results = append(results, v) - } - count := int(len(response.Results)) - totalCount += count - request.Page++ - limit := request.PageSize + seen[id] = true + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } // QueryNameToIdMap calls [QueriesAPI.ListAll] and creates a map of results with [Query].Name as key and [Query].Id as value. @@ -818,15 +810,23 @@ func (a *QueryHistoryAPI) Impl() QueryHistoryService { // // This method is generated by Databricks SDK Code Generator. func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequest) *listing.Iterator[ListQueryHistoryRequest, *ListQueriesResponse, QueryInfo] { + getNextPage := func(ctx context.Context, req ListQueryHistoryRequest) (*ListQueriesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListQueriesResponse) []QueryInfo { return resp.Res } - getNextReq := func(resp *ListQueriesResponse) ListQueryHistoryRequest { + getNextReq := func(resp *ListQueriesResponse) (ListQueryHistoryRequest, listing.ListingStatus) { request.PageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -838,30 +838,22 @@ func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequ func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) { var results []QueryInfo var totalCount int = 0 - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err - } - if len(response.Res) == 0 { - break - } - for _, v := range response.Res { - results = append(results, v) - } - count := int(len(response.Res)) - totalCount += count - request.PageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } - limit := request.MaxResults + limit := request.MaxResults + iter := a.List(ctx, request) + var err error + var next QueryInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + totalCount++ if limit > 0 && totalCount >= limit { break } } - return results, nil + if err != nil { + return nil, err + } + return results, err } func NewQueryVisualizations(client *client.DatabricksClient) *QueryVisualizationsAPI { @@ -1431,7 +1423,9 @@ func (a *WarehousesAPI) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWo // // This method is generated by Databricks SDK Code Generator. func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) *listing.Iterator[ListWarehousesRequest, *ListWarehousesResponse, EndpointInfo] { + getNextPage := func(ctx context.Context, req ListWarehousesRequest) (*ListWarehousesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListWarehousesResponse) []EndpointInfo { @@ -1446,11 +1440,18 @@ func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) } func (a *WarehousesAPI) ListAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) { - response, err := a.impl.List(ctx, request) + var results []EndpointInfo + iter := a.List(ctx, request) + var err error + var next EndpointInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Warehouses, nil + return results, err } // EndpointInfoNameToIdMap calls [WarehousesAPI.ListAll] and creates a map of results with [EndpointInfo].Name as key and [EndpointInfo].Id as value. diff --git a/service/sql/model.go b/service/sql/model.go index d4db5f8a3..8e2fc3298 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -280,7 +280,6 @@ 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/workspace/api.go b/service/workspace/api.go index c1bd97d00..a3aeeae8f 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -93,7 +93,9 @@ func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId // // This method is generated by Databricks SDK Code Generator. func (a *GitCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetCredentialsResponse, CredentialInfo] { + getNextPage := func(ctx context.Context, req struct{}) (*GetCredentialsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx) } getItems := func(resp *GetCredentialsResponse) []CredentialInfo { @@ -108,11 +110,18 @@ func (a *GitCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{} } func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error) { - response, err := a.impl.List(ctx) + var results []CredentialInfo + iter := a.List(ctx) + var err error + var next CredentialInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Credentials, nil + return results, err } // CredentialInfoGitProviderToCredentialIdMap calls [GitCredentialsAPI.ListAll] and creates a map of results with [CredentialInfo].GitProvider as key and [CredentialInfo].CredentialId as value. @@ -293,15 +302,23 @@ func (a *ReposAPI) GetPermissionsByRepoId(ctx context.Context, repoId string) (* // // This method is generated by Databricks SDK Code Generator. func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing.Iterator[ListReposRequest, *ListReposResponse, RepoInfo] { + getNextPage := func(ctx context.Context, req ListReposRequest) (*ListReposResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListReposResponse) []RepoInfo { return resp.Repos } - getNextReq := func(resp *ListReposResponse) ListReposRequest { + getNextReq := func(resp *ListReposResponse) (ListReposRequest, listing.ListingStatus) { request.NextPageToken = resp.NextPageToken - return request + var status listing.ListingStatus + if resp.NextPageToken == "" { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + } + return request, status } return listing.NewIterator( request, @@ -312,24 +329,17 @@ func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing. func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error) { var results []RepoInfo - ctx = useragent.InContext(ctx, "sdk-feature", "pagination") - for { - response, err := a.impl.List(ctx, request) - if err != nil { - return nil, err - } - if len(response.Repos) == 0 { - break - } - for _, v := range response.Repos { - results = append(results, v) - } - request.NextPageToken = response.NextPageToken - if response.NextPageToken == "" { - break - } + iter := a.List(ctx, request) + var err error + var next RepoInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } + if err != nil { + return nil, err } - return results, nil + return results, err } // RepoInfoPathToIdMap calls [ReposAPI.ListAll] and creates a map of results with [RepoInfo].Path as key and [RepoInfo].Id as value. @@ -545,7 +555,9 @@ func (a *SecretsAPI) GetSecret(ctx context.Context, request GetSecretRequest) (* // // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *listing.Iterator[ListAclsRequest, *ListAclsResponse, AclItem] { + getNextPage := func(ctx context.Context, req ListAclsRequest) (*ListAclsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListAcls(ctx, req) } getItems := func(resp *ListAclsResponse) []AclItem { @@ -560,11 +572,18 @@ func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *lis } func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) { - response, err := a.impl.ListAcls(ctx, request) + var results []AclItem + iter := a.ListAcls(ctx, request) + var err error + var next AclItem + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Items, nil + return results, err } // Lists ACLs. @@ -590,7 +609,9 @@ func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAc // // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.Iterator[struct{}, *ListScopesResponse, SecretScope] { + getNextPage := func(ctx context.Context, req struct{}) (*ListScopesResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListScopes(ctx) } getItems := func(resp *ListScopesResponse) []SecretScope { @@ -605,11 +626,18 @@ func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.Iterator[struct{}, } func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { - response, err := a.impl.ListScopes(ctx) + var results []SecretScope + iter := a.ListScopes(ctx) + var err error + var next SecretScope + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Scopes, nil + return results, err } // List secret keys. @@ -625,7 +653,9 @@ func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { // // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) *listing.Iterator[ListSecretsRequest, *ListSecretsResponse, SecretMetadata] { + getNextPage := func(ctx context.Context, req ListSecretsRequest) (*ListSecretsResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.ListSecrets(ctx, req) } getItems := func(resp *ListSecretsResponse) []SecretMetadata { @@ -640,11 +670,18 @@ func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest } func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) { - response, err := a.impl.ListSecrets(ctx, request) + var results []SecretMetadata + iter := a.ListSecrets(ctx, request) + var err error + var next SecretMetadata + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Secrets, nil + return results, err } // List secret keys. @@ -853,7 +890,9 @@ func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error { // // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) *listing.Iterator[ListWorkspaceRequest, *ListResponse, ObjectInfo] { + getNextPage := func(ctx context.Context, req ListWorkspaceRequest) (*ListResponse, error) { + ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.List(ctx, req) } getItems := func(resp *ListResponse) []ObjectInfo { @@ -868,11 +907,18 @@ func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) * } func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error) { - response, err := a.impl.List(ctx, request) + var results []ObjectInfo + iter := a.List(ctx, request) + var err error + var next ObjectInfo + for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + + results = append(results, next) + } if err != nil { return nil, err } - return response.Objects, nil + return results, err } // ObjectInfoPathToObjectIdMap calls [WorkspaceAPI.ListAll] and creates a map of results with [ObjectInfo].Path as key and [ObjectInfo].ObjectId as value. From 05acf98a3328c40b37ff32ce6ca9b715828891ec Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 19 Oct 2023 15:40:31 +0200 Subject: [PATCH 04/24] fix --- .codegen/api.go.tmpl | 4 +- service/billing/api.go | 8 ++-- service/catalog/api.go | 60 ++++++++++++------------- service/compute/api.go | 32 ++++++------- service/files/api.go | 4 +- service/iam/api.go | 28 ++++++------ service/iam/model.go | 4 +- service/jobs/api.go | 8 ++-- service/ml/api.go | 44 +++++++++--------- service/ml/model_registry_usage_test.go | 12 ++--- service/oauth2/api.go | 16 +++---- service/pipelines/api.go | 8 ++-- service/serving/api.go | 4 +- service/settings/api.go | 16 +++---- service/sharing/api.go | 20 ++++----- service/sql/api.go | 16 +++---- service/workspace/api.go | 24 +++++----- 17 files changed, 154 insertions(+), 154 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 1ec13cc82..949a656a8 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -231,10 +231,10 @@ func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Reque } {{- end -}} } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } {{end}}{{if .NamedIdMap}} // {{.NamedIdMap.PascalName}} calls [{{.Service.Name}}API.{{.PascalName}}{{if not .NamedIdMap.Direct}}All{{end -}}] and creates a map of results with [{{.NamedIdMap.Entity.PascalName}}]{{ template "field-path" .NamedIdMap.NamePath }} as key and [{{.NamedIdMap.Entity.PascalName}}]{{ template "field-path" .NamedIdMap.IdPath}} as value. diff --git a/service/billing/api.go b/service/billing/api.go index 7ec3c53d6..1c4dec01a 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -157,10 +157,10 @@ func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // BudgetWithStatusNameToBudgetIdMap calls [BudgetsAPI.ListAll] and creates a map of results with [BudgetWithStatus].Name as key and [BudgetWithStatus].BudgetId as value. @@ -392,10 +392,10 @@ func (a *LogDeliveryAPI) ListAll(ctx context.Context, request ListLogDeliveryReq results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // LogDeliveryConfigurationConfigNameToConfigIdMap calls [LogDeliveryAPI.ListAll] and creates a map of results with [LogDeliveryConfiguration].ConfigName as key and [LogDeliveryConfiguration].ConfigId as value. diff --git a/service/catalog/api.go b/service/catalog/api.go index 8c6b74968..630b4544f 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -119,10 +119,10 @@ func (a *AccountMetastoreAssignmentsAPI) ListAll(ctx context.Context, request Li results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Get all workspaces assigned to a metastore. @@ -241,10 +241,10 @@ func (a *AccountMetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, er results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Update a metastore. @@ -586,10 +586,10 @@ func (a *CatalogsAPI) ListAll(ctx context.Context) ([]CatalogInfo, error) { results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Update a catalog. @@ -712,10 +712,10 @@ func (a *ConnectionsAPI) ListAll(ctx context.Context) ([]ConnectionInfo, error) results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // ConnectionInfoNameToFullNameMap calls [ConnectionsAPI.ListAll] and creates a map of results with [ConnectionInfo].Name as key and [ConnectionInfo].FullName as value. @@ -899,10 +899,10 @@ func (a *ExternalLocationsAPI) ListAll(ctx context.Context) ([]ExternalLocationI results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Update an external location. @@ -1050,10 +1050,10 @@ func (a *FunctionsAPI) ListAll(ctx context.Context, request ListFunctionsRequest results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // FunctionInfoNameToFullNameMap calls [FunctionsAPI.ListAll] and creates a map of results with [FunctionInfo].Name as key and [FunctionInfo].FullName as value. @@ -1310,10 +1310,10 @@ func (a *MetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // MetastoreInfoNameToMetastoreIdMap calls [MetastoresAPI.ListAll] and creates a map of results with [MetastoreInfo].Name as key and [MetastoreInfo].MetastoreId as value. @@ -1585,10 +1585,10 @@ func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersion break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List Model Versions. @@ -1836,10 +1836,10 @@ func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegistere break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // RegisteredModelInfoNameToFullNameMap calls [RegisteredModelsAPI.ListAll] and creates a map of results with [RegisteredModelInfo].Name as key and [RegisteredModelInfo].FullName as value. @@ -2035,10 +2035,10 @@ func (a *SchemasAPI) ListAll(ctx context.Context, request ListSchemasRequest) ([ results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // SchemaInfoNameToFullNameMap calls [SchemasAPI.ListAll] and creates a map of results with [SchemaInfo].Name as key and [SchemaInfo].FullName as value. @@ -2224,10 +2224,10 @@ func (a *StorageCredentialsAPI) ListAll(ctx context.Context) ([]StorageCredentia results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // StorageCredentialInfoNameToIdMap calls [StorageCredentialsAPI.ListAll] and creates a map of results with [StorageCredentialInfo].Name as key and [StorageCredentialInfo].Id as value. @@ -2368,10 +2368,10 @@ func (a *SystemSchemasAPI) ListAll(ctx context.Context, request ListSystemSchema results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List system schemas. @@ -2606,10 +2606,10 @@ func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]T break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // TableInfoNameToTableIdMap calls [TablesAPI.ListAll] and creates a map of results with [TableInfo].Name as key and [TableInfo].TableId as value. @@ -2721,10 +2721,10 @@ func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesR break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Update a table owner. @@ -2863,10 +2863,10 @@ func (a *VolumesAPI) ListAll(ctx context.Context, request ListVolumesRequest) ([ results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // VolumeInfoNameToVolumeIdMap calls [VolumesAPI.ListAll] and creates a map of results with [VolumeInfo].Name as key and [VolumeInfo].VolumeId as value. diff --git a/service/compute/api.go b/service/compute/api.go index 59af0df19..3c9695dde 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -180,10 +180,10 @@ func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request ListClusterPol results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // PolicyNameToPolicyIdMap calls [ClusterPoliciesAPI.ListAll] and creates a map of results with [Policy].Name as key and [Policy].PolicyId as value. @@ -643,10 +643,10 @@ func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]Clust break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Get cluster info. @@ -740,10 +740,10 @@ func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // ClusterDetailsClusterNameToClusterIdMap calls [ClustersAPI.ListAll] and creates a map of results with [ClusterDetails].ClusterName as key and [ClusterDetails].ClusterId as value. @@ -1578,10 +1578,10 @@ func (a *GlobalInitScriptsAPI) ListAll(ctx context.Context) ([]GlobalInitScriptD results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // GlobalInitScriptDetailsNameToScriptIdMap calls [GlobalInitScriptsAPI.ListAll] and creates a map of results with [GlobalInitScriptDetails].Name as key and [GlobalInitScriptDetails].ScriptId as value. @@ -1802,10 +1802,10 @@ func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap calls [InstancePoolsAPI.ListAll] and creates a map of results with [InstancePoolAndStats].InstancePoolName as key and [InstancePoolAndStats].InstancePoolId as value. @@ -1971,10 +1971,10 @@ func (a *InstanceProfilesAPI) ListAll(ctx context.Context) ([]InstanceProfile, e results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Remove the instance profile. @@ -2100,10 +2100,10 @@ func (a *LibrariesAPI) ClusterStatusAll(ctx context.Context, request ClusterStat results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Get status. @@ -2247,8 +2247,8 @@ func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamil break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } diff --git a/service/files/api.go b/service/files/api.go index af566f738..883db132a 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -168,10 +168,10 @@ func (a *DbfsAPI) ListAll(ctx context.Context, request ListDbfsRequest) ([]FileI results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List directory contents or file details. diff --git a/service/iam/api.go b/service/iam/api.go index 597d7c043..f77095f2b 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -229,10 +229,10 @@ func (a *AccountGroupsAPI) ListAll(ctx context.Context, request ListAccountGroup results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // GroupDisplayNameToIdMap calls [AccountGroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -406,10 +406,10 @@ func (a *AccountServicePrincipalsAPI) ListAll(ctx context.Context, request ListA results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // ServicePrincipalDisplayNameToIdMap calls [AccountServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -592,10 +592,10 @@ func (a *AccountUsersAPI) ListAll(ctx context.Context, request ListAccountUsersR results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // UserUserNameToIdMap calls [AccountUsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -805,10 +805,10 @@ func (a *GroupsAPI) ListAll(ctx context.Context, request ListGroupsRequest) ([]G results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // GroupDisplayNameToIdMap calls [GroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -1107,10 +1107,10 @@ func (a *ServicePrincipalsAPI) ListAll(ctx context.Context, request ListServiceP results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // ServicePrincipalDisplayNameToIdMap calls [ServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -1308,10 +1308,10 @@ func (a *UsersAPI) ListAll(ctx context.Context, request ListUsersRequest) ([]Use results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // UserUserNameToIdMap calls [UsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -1495,10 +1495,10 @@ func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorksp results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Get permission assignments. diff --git a/service/iam/model.go b/service/iam/model.go index f13094f41..9b938ff46 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,7 @@ type Group struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks group ID - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Members []ComplexValue `json:"members,omitempty"` // Container for the group identifier. Workspace local versus account. @@ -1024,7 +1024,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty" url:"-"` + Id string `json:"id,omitempty"` Roles []ComplexValue `json:"roles,omitempty"` diff --git a/service/jobs/api.go b/service/jobs/api.go index 912aecb8b..69b9cb85e 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -369,10 +369,10 @@ func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJ break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // BaseJobSettingsNameToJobIdMap calls [JobsAPI.ListAll] and creates a map of results with [BaseJob].Settings.Name as key and [BaseJob].JobId as value. @@ -474,10 +474,10 @@ func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]B break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Repair a job run. diff --git a/service/ml/api.go b/service/ml/api.go index 996a5ec8e..60845fb79 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -168,10 +168,10 @@ func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRe break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Get experiment permission levels. @@ -261,10 +261,10 @@ func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtif results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List experiments. @@ -313,10 +313,10 @@ func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExp break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Log a batch. @@ -464,10 +464,10 @@ func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request Searc results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Search for runs. @@ -512,10 +512,10 @@ func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Set a tag. @@ -723,10 +723,10 @@ func (a *ModelRegistryAPI) GetLatestVersionsAll(ctx context.Context, request Get results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Get model. @@ -835,10 +835,10 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List transition requests. @@ -872,10 +872,10 @@ func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, reques results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List registry webhooks. @@ -920,10 +920,10 @@ func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebh results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Reject a transition request. @@ -986,10 +986,10 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Search models. @@ -1038,10 +1038,10 @@ func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchMo break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Set a tag. diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index 7199cd404..b5ccf9028 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -109,7 +109,7 @@ func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -124,18 +124,18 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { } logger.Infof(ctx, "found %v", model) - created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", mv) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -150,14 +150,14 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { } logger.Infof(ctx, "found %v", model) - mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", mv) + logger.Infof(ctx, "found %v", created) } diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 43be91dc1..d9b85ab93 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -116,10 +116,10 @@ func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIn results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Updates Custom OAuth App Integration. @@ -262,10 +262,10 @@ func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPu break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } func NewPublishedAppIntegration(client *client.DatabricksClient) *PublishedAppIntegrationAPI { @@ -373,10 +373,10 @@ func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishe results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Updates Published OAuth App Integration. @@ -483,10 +483,10 @@ func (a *ServicePrincipalSecretsAPI) ListAll(ctx context.Context, request ListSe results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List service principal secrets. diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 733463c92..0df9d9f58 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -295,10 +295,10 @@ func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPi break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List pipeline events. @@ -356,10 +356,10 @@ func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelin break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // PipelineStateInfoNameToPipelineIdMap calls [PipelinesAPI.ListPipelinesAll] and creates a map of results with [PipelineStateInfo].Name as key and [PipelineStateInfo].PipelineId as value. diff --git a/service/serving/api.go b/service/serving/api.go index 04f2ba178..c15a651bc 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -279,10 +279,10 @@ func (a *ServingEndpointsAPI) ListAll(ctx context.Context) ([]ServingEndpoint, e results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Retrieve the most recent log lines associated with a given serving endpoint's diff --git a/service/settings/api.go b/service/settings/api.go index 5fe7031d8..60965987b 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -143,10 +143,10 @@ func (a *AccountIpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListIn results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // IpAccessListInfoLabelToListIdMap calls [AccountIpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -463,10 +463,10 @@ func (a *IpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, err results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // IpAccessListInfoLabelToListIdMap calls [IpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -729,10 +729,10 @@ func (a *TokenManagementAPI) ListAll(ctx context.Context, request ListTokenManag results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // TokenInfoCommentToTokenIdMap calls [TokenManagementAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. @@ -895,10 +895,10 @@ func (a *TokensAPI) ListAll(ctx context.Context) ([]TokenInfo, error) { results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // TokenInfoCommentToTokenIdMap calls [TokensAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. diff --git a/service/sharing/api.go b/service/sharing/api.go index 2fb450726..41e95dbf2 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -137,10 +137,10 @@ func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsReque break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Update a clean room. @@ -273,10 +273,10 @@ func (a *ProvidersAPI) ListAll(ctx context.Context, request ListProvidersRequest results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // ProviderInfoNameToMetastoreIdMap calls [ProvidersAPI.ListAll] and creates a map of results with [ProviderInfo].Name as key and [ProviderInfo].MetastoreId as value. @@ -337,10 +337,10 @@ func (a *ProvidersAPI) ListSharesAll(ctx context.Context, request ListSharesRequ results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List shares by Provider. @@ -558,10 +558,10 @@ func (a *RecipientsAPI) ListAll(ctx context.Context, request ListRecipientsReque results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // RecipientInfoNameToMetastoreIdMap calls [RecipientsAPI.ListAll] and creates a map of results with [RecipientInfo].Name as key and [RecipientInfo].MetastoreId as value. @@ -734,10 +734,10 @@ func (a *SharesAPI) ListAll(ctx context.Context) ([]ShareInfo, error) { results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Get permissions. diff --git a/service/sql/api.go b/service/sql/api.go index 669790e00..6bc15a663 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -329,10 +329,10 @@ func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsReque break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // DashboardNameToIdMap calls [DashboardsAPI.ListAll] and creates a map of results with [Dashboard].Name as key and [Dashboard].Id as value. @@ -699,10 +699,10 @@ func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([ break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // QueryNameToIdMap calls [QueriesAPI.ListAll] and creates a map of results with [Query].Name as key and [Query].Id as value. @@ -850,10 +850,10 @@ func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryR break } } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } func NewQueryVisualizations(client *client.DatabricksClient) *QueryVisualizationsAPI { @@ -1448,10 +1448,10 @@ func (a *WarehousesAPI) ListAll(ctx context.Context, request ListWarehousesReque results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // EndpointInfoNameToIdMap calls [WarehousesAPI.ListAll] and creates a map of results with [EndpointInfo].Name as key and [EndpointInfo].Id as value. diff --git a/service/workspace/api.go b/service/workspace/api.go index a3aeeae8f..70d3b10c2 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -118,10 +118,10 @@ func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, erro results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // CredentialInfoGitProviderToCredentialIdMap calls [GitCredentialsAPI.ListAll] and creates a map of results with [CredentialInfo].GitProvider as key and [CredentialInfo].CredentialId as value. @@ -336,10 +336,10 @@ func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]Rep results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // RepoInfoPathToIdMap calls [ReposAPI.ListAll] and creates a map of results with [RepoInfo].Path as key and [RepoInfo].Id as value. @@ -580,10 +580,10 @@ func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ( results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // Lists ACLs. @@ -634,10 +634,10 @@ func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List secret keys. @@ -678,10 +678,10 @@ func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequ results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // List secret keys. @@ -915,10 +915,10 @@ func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest results = append(results, next) } - if err != nil { + if err != listing.ErrNoMoreItems { return nil, err } - return results, err + return results, nil } // ObjectInfoPathToObjectIdMap calls [WorkspaceAPI.ListAll] and creates a map of results with [ObjectInfo].Path as key and [ObjectInfo].ObjectId as value. From b4b5eda4c1468d1f2f463f87982a75740e46735d Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 19 Oct 2023 15:48:15 +0200 Subject: [PATCH 05/24] better handling for cluster events --- .codegen/api.go.tmpl | 11 ++++++++--- service/catalog/api.go | 8 ++++---- service/compute/api.go | 12 +++++++++--- service/iam/model.go | 2 +- service/jobs/api.go | 4 ++-- service/ml/api.go | 18 +++++++++--------- service/ml/model_registry_usage_test.go | 14 +++++++------- service/oauth2/api.go | 2 +- service/pipelines/api.go | 4 ++-- service/sharing/api.go | 2 +- service/sql/api.go | 8 +++++--- service/workspace/api.go | 2 +- 12 files changed, 50 insertions(+), 37 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 949a656a8..166efc83f 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -176,9 +176,9 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} } {{if .Pagination.MultiRequest -}} getNextReq := func(resp *{{ .Response.PascalName }}) ({{.Request.PascalName}}, listing.ListingStatus) { + status := listing.ListingStatusCheckResult {{if .Pagination.Token -}} request.{{.Pagination.Token.PollField.PascalName}} = resp.{{.Pagination.Token.Bind.PascalName}} - var status listing.ListingStatus if resp.{{.Pagination.Token.Bind.PascalName}} == "" { status = listing.ListingStatusExhausted } else { @@ -187,11 +187,16 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} {{- else if eq .Pagination.Increment 1 -}} request.{{.Pagination.Offset.PascalName}} = resp.{{.Pagination.Offset.PascalName}} + 1 {{- else if eq .Path "/api/2.0/clusters/events" -}} - request = *resp.NextPage + if resp.NextPage == nil { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + request = *resp.NextPage + } {{- else -}} request.{{.Pagination.Offset.PascalName}} = resp.{{.Pagination.Offset.PascalName}} + {{template "type" .Pagination.Offset.Entity}}(len(resp.{{.Pagination.Results.PascalName}})) {{- end}} - return request, {{if .Pagination.Token}}status{{else}}listing.ListingStatusCheckResult{{end}} + return request, status } {{- end}} return listing.NewIterator( diff --git a/service/catalog/api.go b/service/catalog/api.go index 630b4544f..cf883a090 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -1554,8 +1554,8 @@ func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRe return resp.ModelVersions } getNextReq := func(resp *ListModelVersionsResponse) (ListModelVersionsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -1805,8 +1805,8 @@ func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredMo return resp.RegisteredModels } getNextReq := func(resp *ListRegisteredModelsResponse) (ListRegisteredModelsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -2575,8 +2575,8 @@ func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listin return resp.Tables } getNextReq := func(resp *ListTablesResponse) (ListTablesRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -2690,8 +2690,8 @@ func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequ return resp.Tables } getNextReq := func(resp *ListTableSummariesResponse) (ListSummariesRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { diff --git a/service/compute/api.go b/service/compute/api.go index 3c9695dde..440bec5b5 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -618,8 +618,14 @@ func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.It return resp.Events } getNextReq := func(resp *GetEventsResponse) (GetEvents, listing.ListingStatus) { - request = *resp.NextPage - return request, listing.ListingStatusCheckResult + status := listing.ListingStatusCheckResult + if resp.NextPage == nil { + status = listing.ListingStatusExhausted + } else { + status = listing.ListingStatusNotExhausted + request = *resp.NextPage + } + return request, status } return listing.NewIterator( request, @@ -2216,8 +2222,8 @@ func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamilies return resp.PolicyFamilies } getNextReq := func(resp *ListPolicyFamiliesResponse) (ListPolicyFamiliesRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { diff --git a/service/iam/model.go b/service/iam/model.go index 9b938ff46..4d1a0f3d0 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,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. diff --git a/service/jobs/api.go b/service/jobs/api.go index 69b9cb85e..82ce15c98 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -338,8 +338,8 @@ func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.It return resp.Jobs } getNextReq := func(resp *ListJobsResponse) (ListJobsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -443,8 +443,8 @@ func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listin return resp.Runs } getNextReq := func(resp *ListRunsResponse) (ListRunsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { diff --git a/service/ml/api.go b/service/ml/api.go index 60845fb79..cf25ff328 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -137,8 +137,8 @@ func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryReque return resp.Metrics } getNextReq := func(resp *GetMetricHistoryResponse) (GetHistoryRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -236,8 +236,8 @@ func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifact return resp.Files } getNextReq := func(resp *ListArtifactsResponse) (ListArtifactsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -282,8 +282,8 @@ func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperi return resp.Experiments } getNextReq := func(resp *ListExperimentsResponse) (ListExperimentsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -439,8 +439,8 @@ func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchEx return resp.Experiments } getNextReq := func(resp *SearchExperimentsResponse) (SearchExperiments, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -487,8 +487,8 @@ func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *li return resp.Runs } getNextReq := func(resp *SearchRunsResponse) (SearchRuns, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -804,8 +804,8 @@ func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsReq return resp.RegisteredModels } getNextReq := func(resp *ListModelsResponse) (ListModelsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -895,8 +895,8 @@ func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhook return resp.Webhooks } getNextReq := func(resp *ListRegistryWebhooks) (ListWebhooksRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -955,8 +955,8 @@ func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request Sear return resp.ModelVersions } getNextReq := func(resp *SearchModelVersionsResponse) (SearchModelVersionsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -1007,8 +1007,8 @@ func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModel return resp.RegisteredModels } getNextReq := func(resp *SearchModelsResponse) (SearchModelsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index b5ccf9028..4d28afe5d 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -58,41 +58,41 @@ func ExampleModelRegistryAPI_CreateComment_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_models() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", model) } -func ExampleModelRegistryAPI_CreateModel_modelVersions() { +func ExampleModelRegistryAPI_CreateModel_models() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", model) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { diff --git a/service/oauth2/api.go b/service/oauth2/api.go index d9b85ab93..0791f1fd7 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -231,8 +231,8 @@ func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPubli return resp.Apps } getNextReq := func(resp *GetPublishedAppsOutput) (ListOAuthPublishedAppsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 0df9d9f58..45bb21dec 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -264,8 +264,8 @@ func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipel return resp.Events } getNextReq := func(resp *ListPipelineEventsResponse) (ListPipelineEventsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { @@ -325,8 +325,8 @@ func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesR return resp.Statuses } getNextReq := func(resp *ListPipelinesResponse) (ListPipelinesRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { diff --git a/service/sharing/api.go b/service/sharing/api.go index 41e95dbf2..8adfe77bd 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -106,8 +106,8 @@ func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) return resp.CleanRooms } getNextReq := func(resp *ListCleanRoomsResponse) (ListCleanRoomsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { diff --git a/service/sql/api.go b/service/sql/api.go index 6bc15a663..52b77c792 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -297,8 +297,9 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) return resp.Results } getNextReq := func(resp *ListResponse) (ListDashboardsRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.Page = resp.Page + 1 - return request, listing.ListingStatusCheckResult + return request, status } return listing.NewIterator( request, @@ -667,8 +668,9 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *list return resp.Results } getNextReq := func(resp *QueryList) (ListQueriesRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.Page = resp.Page + 1 - return request, listing.ListingStatusCheckResult + return request, status } return listing.NewIterator( request, @@ -819,8 +821,8 @@ func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequ return resp.Res } getNextReq := func(resp *ListQueriesResponse) (ListQueryHistoryRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.PageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { diff --git a/service/workspace/api.go b/service/workspace/api.go index 70d3b10c2..c0958a9f6 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -311,8 +311,8 @@ func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing. return resp.Repos } getNextReq := func(resp *ListReposResponse) (ListReposRequest, listing.ListingStatus) { + status := listing.ListingStatusCheckResult request.NextPageToken = resp.NextPageToken - var status listing.ListingStatus if resp.NextPageToken == "" { status = listing.ListingStatusExhausted } else { From 661ca7ed56ca195f3decbfa408dfd6e014d99a33 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 19 Oct 2023 15:51:42 +0200 Subject: [PATCH 06/24] bugfix --- listing/listing.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/listing/listing.go b/listing/listing.go index 708cf3f54..0b70cdd71 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -51,17 +51,16 @@ func NewIterator[Req, Resp, T any]( } } -func (i *Iterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) (bool, error) { +func (i *Iterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error { if i.currentPageIdx < len(i.currentPage) { - return true, nil + return nil } - if i.isExhausted { - return false, ErrNoMoreItems + return ErrNoMoreItems } resp, err := i.getNextPage(ctx, i.nextReq) if err != nil { - return false, err + return err } items := i.getItems(resp) i.currentPage = items @@ -71,16 +70,16 @@ func (i *Iterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) (bool if !i.isExhausted && (status == ListingStatusExhausted || (status == ListingStatusCheckResult && len(items) == 0)) { i.isExhausted = true } - return !i.isExhausted, err + return err } func (i *Iterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { var t T - ok, err := i.loadNextPageIfNeeded(ctx) + err := i.loadNextPageIfNeeded(ctx) if err != nil { return t, err } - if !ok { + if i.currentPageIdx >= len(i.currentPage) { return t, ErrNoMoreItems } item := i.currentPage[i.currentPageIdx] @@ -89,5 +88,9 @@ func (i *Iterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { } func (i *Iterator[Req, Resp, T]) HasNext(ctx context.Context) (bool, error) { - return i.loadNextPageIfNeeded(ctx) + err := i.loadNextPageIfNeeded(ctx) + if err != nil { + return false, err + } + return i.currentPageIdx < len(i.currentPage), nil } From 68f4e702abe695697346afac3ed677d52639dfbf Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 19 Oct 2023 15:59:04 +0200 Subject: [PATCH 07/24] comments and test --- listing/listing.go | 30 ++++++++++++++++++++---------- listing/listing_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 listing/listing_test.go diff --git a/listing/listing.go b/listing/listing.go index 0b70cdd71..a57b2a224 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -13,26 +13,36 @@ const ( ListingStatusExhausted ListingStatus = iota // ListingStatusNotExhausted indicates that the iterator is not exhausted // and there are more items to be fetched. - ListingStatusNotExhausted ListingStatus = iota + ListingStatusNotExhausted // ListingStatusCheckResult indicates that the iterator is exhausted if and // only if there are no results returned. - ListingStatusCheckResult ListingStatus = iota + ListingStatusCheckResult ) // Use struct{} for Req to indicate one-shot iterator. type Iterator[Req, Resp, T any] struct { - nextReq Req + // nextReq is the request to be used to fetch the next page. + nextReq Req + + // getNextPage fetches the next page of items, returning the deserialized + // response and error. getNextPage func(context.Context, Req) (Resp, error) - getItems func(Resp) []T + + // getItems selects the items being iterated over from the response. + getItems func(Resp) []T // getNextReq is used to get the next request to be used in the next page. - // The returned boolean value indicates whether the iterator is exhausted - // without needing to fetch the next page (e.g. token-based pagination where - // no next page token is provided in the response). - getNextReq func(Resp) (Req, ListingStatus) - currentPage []T + // The ListingStatus value indicates whether the client can stop iterating. + getNextReq func(Resp) (Req, ListingStatus) + + // currentPage is the current page of items. + currentPage []T + + // currentPageIdx is the index of the next item from currentPage to return. currentPageIdx int - isExhausted bool + + // isExhausted indicates whether there are no more items to be fetched. + isExhausted bool } var ErrNoMoreItems = errors.New("no more items") diff --git a/listing/listing_test.go b/listing/listing_test.go new file mode 100644 index 000000000..2ecc7a89f --- /dev/null +++ b/listing/listing_test.go @@ -0,0 +1,40 @@ +package listing + +import ( + "context" + "errors" + "testing" +) + +// TestIterator tests the Iterator type. +func TestIterator(t *testing.T) { + getNextPage := func(ctx context.Context, req int) ([]int, error) { + if req >= 10 { + return nil, nil + } + return []int{req, req + 1}, nil + } + getNextReq := func(resp []int) (int, ListingStatus) { + if len(resp) == 0 { + return 0, ListingStatusExhausted + } + return resp[len(resp)-1] + 1, ListingStatusCheckResult + } + getItems := func(resp []int) []int { + return resp + } + it := NewIterator(0, getNextPage, getItems, getNextReq) + for i := 0; i < 10; i++ { + v, err := it.Next(context.Background()) + if err != nil { + t.Fatal(err) + } + if v != i { + t.Fatalf("expected %d, got %d", i, v) + } + } + _, err := it.Next(context.Background()) + if !errors.Is(err, ErrNoMoreItems) { + t.Fatalf("expected %v, got %v", ErrNoMoreItems, err) + } +} \ No newline at end of file From 40b351f21fe85faf2d48c4e21bdf288c9a6ee0fc Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 19 Oct 2023 17:34:20 +0200 Subject: [PATCH 08/24] tests passing --- .codegen/api.go.tmpl | 4 +- listing/listing.go | 6 ++- listing/listing_test.go | 2 +- service/billing/api.go | 9 ++-- service/catalog/api.go | 61 +++++++++++++------------ service/compute/api.go | 33 ++++++------- service/files/api.go | 5 +- service/iam/api.go | 29 ++++++------ service/iam/model.go | 6 +-- service/jobs/api.go | 9 ++-- service/ml/api.go | 45 +++++++++--------- service/ml/model_registry_usage_test.go | 14 +++--- service/oauth2/api.go | 17 +++---- service/pipelines/api.go | 9 ++-- service/serving/api.go | 5 +- service/settings/api.go | 17 +++---- service/sharing/api.go | 21 +++++---- service/sql/api.go | 17 +++---- service/sql/model.go | 1 + service/workspace/api.go | 25 +++++----- 20 files changed, 177 insertions(+), 158 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 166efc83f..d7dbd6780 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -219,7 +219,7 @@ func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Reque {{end -}} var err error var next {{ template "type" .Pagination.Entity }} - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { {{ if .NeedsOffsetDedupe -}} id := next{{ template "field-path" .IdFieldPath }} if seen[id] { @@ -236,7 +236,7 @@ func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Reque } {{- end -}} } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/listing/listing.go b/listing/listing.go index a57b2a224..7d1615f0b 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -76,7 +76,11 @@ func (i *Iterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error i.currentPage = items i.currentPageIdx = 0 var status ListingStatus - i.nextReq, status = i.getNextReq(resp) + if i.getNextReq == nil { + status = ListingStatusExhausted + } else { + i.nextReq, status = i.getNextReq(resp) + } if !i.isExhausted && (status == ListingStatusExhausted || (status == ListingStatusCheckResult && len(items) == 0)) { i.isExhausted = true } diff --git a/listing/listing_test.go b/listing/listing_test.go index 2ecc7a89f..49d438c74 100644 --- a/listing/listing_test.go +++ b/listing/listing_test.go @@ -37,4 +37,4 @@ func TestIterator(t *testing.T) { if !errors.Is(err, ErrNoMoreItems) { t.Fatalf("expected %v, got %v", ErrNoMoreItems, err) } -} \ No newline at end of file +} diff --git a/service/billing/api.go b/service/billing/api.go index 1c4dec01a..c652d6e9b 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -5,6 +5,7 @@ package billing import ( "context" + "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -153,11 +154,11 @@ func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { iter := a.List(ctx) var err error var next BudgetWithStatus - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -388,11 +389,11 @@ func (a *LogDeliveryAPI) ListAll(ctx context.Context, request ListLogDeliveryReq iter := a.List(ctx, request) var err error var next LogDeliveryConfiguration - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/catalog/api.go b/service/catalog/api.go index cf883a090..e2de25631 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -5,6 +5,7 @@ package catalog import ( "context" + "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -115,11 +116,11 @@ func (a *AccountMetastoreAssignmentsAPI) ListAll(ctx context.Context, request Li iter := a.List(ctx, request) var err error var next int64 - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -237,11 +238,11 @@ func (a *AccountMetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, er iter := a.List(ctx) var err error var next MetastoreInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -582,11 +583,11 @@ func (a *CatalogsAPI) ListAll(ctx context.Context) ([]CatalogInfo, error) { iter := a.List(ctx) var err error var next CatalogInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -708,11 +709,11 @@ func (a *ConnectionsAPI) ListAll(ctx context.Context) ([]ConnectionInfo, error) iter := a.List(ctx) var err error var next ConnectionInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -895,11 +896,11 @@ func (a *ExternalLocationsAPI) ListAll(ctx context.Context) ([]ExternalLocationI iter := a.List(ctx) var err error var next ExternalLocationInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1046,11 +1047,11 @@ func (a *FunctionsAPI) ListAll(ctx context.Context, request ListFunctionsRequest iter := a.List(ctx, request) var err error var next FunctionInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1306,11 +1307,11 @@ func (a *MetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { iter := a.List(ctx) var err error var next MetastoreInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1577,7 +1578,7 @@ func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersion iter := a.List(ctx, request) var err error var next ModelVersionInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -1585,7 +1586,7 @@ func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersion break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1828,7 +1829,7 @@ func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegistere iter := a.List(ctx, request) var err error var next RegisteredModelInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -1836,7 +1837,7 @@ func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegistere break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -2031,11 +2032,11 @@ func (a *SchemasAPI) ListAll(ctx context.Context, request ListSchemasRequest) ([ iter := a.List(ctx, request) var err error var next SchemaInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -2220,11 +2221,11 @@ func (a *StorageCredentialsAPI) ListAll(ctx context.Context) ([]StorageCredentia iter := a.List(ctx) var err error var next StorageCredentialInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -2364,11 +2365,11 @@ func (a *SystemSchemasAPI) ListAll(ctx context.Context, request ListSystemSchema iter := a.List(ctx, request) var err error var next SystemSchemaInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -2598,7 +2599,7 @@ func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]T iter := a.List(ctx, request) var err error var next TableInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -2606,7 +2607,7 @@ func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]T break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -2713,7 +2714,7 @@ func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesR iter := a.ListSummaries(ctx, request) var err error var next TableSummary - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -2721,7 +2722,7 @@ func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesR break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -2859,11 +2860,11 @@ func (a *VolumesAPI) ListAll(ctx context.Context, request ListVolumesRequest) ([ iter := a.List(ctx, request) var err error var next VolumeInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/compute/api.go b/service/compute/api.go index 440bec5b5..6a949cdec 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -5,6 +5,7 @@ package compute import ( "context" + "errors" "fmt" "time" @@ -176,11 +177,11 @@ func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request ListClusterPol iter := a.List(ctx, request) var err error var next Policy - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -641,7 +642,7 @@ func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]Clust iter := a.Events(ctx, request) var err error var next ClusterEvent - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -649,7 +650,7 @@ func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]Clust break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -742,11 +743,11 @@ func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) iter := a.List(ctx, request) var err error var next ClusterDetails - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1580,11 +1581,11 @@ func (a *GlobalInitScriptsAPI) ListAll(ctx context.Context) ([]GlobalInitScriptD iter := a.List(ctx) var err error var next GlobalInitScriptDetails - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1804,11 +1805,11 @@ func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, iter := a.List(ctx) var err error var next InstancePoolAndStats - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1973,11 +1974,11 @@ func (a *InstanceProfilesAPI) ListAll(ctx context.Context) ([]InstanceProfile, e iter := a.List(ctx) var err error var next InstanceProfile - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -2102,11 +2103,11 @@ func (a *LibrariesAPI) ClusterStatusAll(ctx context.Context, request ClusterStat iter := a.ClusterStatus(ctx, request) var err error var next LibraryFullStatus - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -2245,7 +2246,7 @@ func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamil iter := a.List(ctx, request) var err error var next PolicyFamily - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -2253,7 +2254,7 @@ func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamil break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/files/api.go b/service/files/api.go index 883db132a..1cf6a673e 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -5,6 +5,7 @@ package files import ( "context" + "errors" "github.com/databricks/databricks-sdk-go/client" "github.com/databricks/databricks-sdk-go/listing" @@ -164,11 +165,11 @@ func (a *DbfsAPI) ListAll(ctx context.Context, request ListDbfsRequest) ([]FileI iter := a.List(ctx, request) var err error var next FileInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/iam/api.go b/service/iam/api.go index f77095f2b..54a388478 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -5,6 +5,7 @@ package iam import ( "context" + "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -225,11 +226,11 @@ func (a *AccountGroupsAPI) ListAll(ctx context.Context, request ListAccountGroup iter := a.List(ctx, request) var err error var next Group - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -402,11 +403,11 @@ func (a *AccountServicePrincipalsAPI) ListAll(ctx context.Context, request ListA iter := a.List(ctx, request) var err error var next ServicePrincipal - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -588,11 +589,11 @@ func (a *AccountUsersAPI) ListAll(ctx context.Context, request ListAccountUsersR iter := a.List(ctx, request) var err error var next User - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -801,11 +802,11 @@ func (a *GroupsAPI) ListAll(ctx context.Context, request ListGroupsRequest) ([]G iter := a.List(ctx, request) var err error var next Group - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1103,11 +1104,11 @@ func (a *ServicePrincipalsAPI) ListAll(ctx context.Context, request ListServiceP iter := a.List(ctx, request) var err error var next ServicePrincipal - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1304,11 +1305,11 @@ func (a *UsersAPI) ListAll(ctx context.Context, request ListUsersRequest) ([]Use iter := a.List(ctx, request) var err error var next User - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1491,11 +1492,11 @@ func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorksp iter := a.List(ctx, request) var err error var next PermissionAssignment - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/iam/model.go b/service/iam/model.go index 4d1a0f3d0..e65f2492f 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,7 @@ type Group struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks group ID - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Members []ComplexValue `json:"members,omitempty"` // Container for the group identifier. Workspace local versus account. @@ -1024,7 +1024,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Roles []ComplexValue `json:"roles,omitempty"` @@ -1070,7 +1070,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 82ce15c98..72217f0af 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -5,6 +5,7 @@ package jobs import ( "context" + "errors" "fmt" "time" @@ -361,7 +362,7 @@ func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJ iter := a.List(ctx, request) var err error var next BaseJob - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -369,7 +370,7 @@ func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJ break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -466,7 +467,7 @@ func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]B iter := a.ListRuns(ctx, request) var err error var next BaseRun - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -474,7 +475,7 @@ func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]B break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/ml/api.go b/service/ml/api.go index cf25ff328..baf207f9e 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -5,6 +5,7 @@ package ml import ( "context" + "errors" "github.com/databricks/databricks-sdk-go/client" "github.com/databricks/databricks-sdk-go/listing" @@ -160,7 +161,7 @@ func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRe iter := a.GetHistory(ctx, request) var err error var next Metric - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -168,7 +169,7 @@ func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRe break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -257,11 +258,11 @@ func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtif iter := a.ListArtifacts(ctx, request) var err error var next FileInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -305,7 +306,7 @@ func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExp iter := a.ListExperiments(ctx, request) var err error var next Experiment - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -313,7 +314,7 @@ func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExp break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -460,11 +461,11 @@ func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request Searc iter := a.SearchExperiments(ctx, request) var err error var next Experiment - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -508,11 +509,11 @@ func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) iter := a.SearchRuns(ctx, request) var err error var next Run - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -719,11 +720,11 @@ func (a *ModelRegistryAPI) GetLatestVersionsAll(ctx context.Context, request Get iter := a.GetLatestVersions(ctx, request) var err error var next ModelVersion - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -827,7 +828,7 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels iter := a.ListModels(ctx, request) var err error var next Model - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -835,7 +836,7 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -868,11 +869,11 @@ func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, reques iter := a.ListTransitionRequests(ctx, request) var err error var next Activity - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -916,11 +917,11 @@ func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebh iter := a.ListWebhooks(ctx, request) var err error var next RegistryWebhook - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -978,7 +979,7 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S iter := a.SearchModelVersions(ctx, request) var err error var next ModelVersion - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -986,7 +987,7 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1030,7 +1031,7 @@ func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchMo iter := a.SearchModels(ctx, request) var err error var next Model - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -1038,7 +1039,7 @@ func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchMo break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index 4d28afe5d..b5ccf9028 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -58,41 +58,41 @@ func ExampleModelRegistryAPI_CreateComment_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_models() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", model) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModel_models() { +func ExampleModelRegistryAPI_CreateModel_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", model) } -func ExampleModelRegistryAPI_CreateModel_modelVersions() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 0791f1fd7..3386d9059 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -5,6 +5,7 @@ package oauth2 import ( "context" + "errors" "github.com/databricks/databricks-sdk-go/client" "github.com/databricks/databricks-sdk-go/listing" @@ -112,11 +113,11 @@ func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIn iter := a.List(ctx) var err error var next GetCustomAppIntegrationOutput - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -254,7 +255,7 @@ func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPu iter := a.List(ctx, request) var err error var next PublishedAppOutput - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -262,7 +263,7 @@ func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPu break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -369,11 +370,11 @@ func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishe iter := a.List(ctx) var err error var next GetPublishedAppIntegrationOutput - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -479,11 +480,11 @@ func (a *ServicePrincipalSecretsAPI) ListAll(ctx context.Context, request ListSe iter := a.List(ctx, request) var err error var next SecretInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 45bb21dec..696575635 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -5,6 +5,7 @@ package pipelines import ( "context" + "errors" "fmt" "time" @@ -287,7 +288,7 @@ func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPi iter := a.ListPipelineEvents(ctx, request) var err error var next PipelineEvent - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -295,7 +296,7 @@ func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPi break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -348,7 +349,7 @@ func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelin iter := a.ListPipelines(ctx, request) var err error var next PipelineStateInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -356,7 +357,7 @@ func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelin break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/serving/api.go b/service/serving/api.go index c15a651bc..d72013e85 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -5,6 +5,7 @@ package serving import ( "context" + "errors" "fmt" "time" @@ -275,11 +276,11 @@ func (a *ServingEndpointsAPI) ListAll(ctx context.Context) ([]ServingEndpoint, e iter := a.List(ctx) var err error var next ServingEndpoint - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/settings/api.go b/service/settings/api.go index 60965987b..906587000 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -5,6 +5,7 @@ package settings import ( "context" + "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -139,11 +140,11 @@ func (a *AccountIpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListIn iter := a.List(ctx) var err error var next IpAccessListInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -459,11 +460,11 @@ func (a *IpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, err iter := a.List(ctx) var err error var next IpAccessListInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -725,11 +726,11 @@ func (a *TokenManagementAPI) ListAll(ctx context.Context, request ListTokenManag iter := a.List(ctx, request) var err error var next TokenInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -891,11 +892,11 @@ func (a *TokensAPI) ListAll(ctx context.Context) ([]TokenInfo, error) { iter := a.List(ctx) var err error var next TokenInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/sharing/api.go b/service/sharing/api.go index 8adfe77bd..ded51dfdd 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -5,6 +5,7 @@ package sharing import ( "context" + "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -129,7 +130,7 @@ func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsReque iter := a.List(ctx, request) var err error var next CleanRoomInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -137,7 +138,7 @@ func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsReque break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -269,11 +270,11 @@ func (a *ProvidersAPI) ListAll(ctx context.Context, request ListProvidersRequest iter := a.List(ctx, request) var err error var next ProviderInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -333,11 +334,11 @@ func (a *ProvidersAPI) ListSharesAll(ctx context.Context, request ListSharesRequ iter := a.ListShares(ctx, request) var err error var next ProviderShare - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -554,11 +555,11 @@ func (a *RecipientsAPI) ListAll(ctx context.Context, request ListRecipientsReque iter := a.List(ctx, request) var err error var next RecipientInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -730,11 +731,11 @@ func (a *SharesAPI) ListAll(ctx context.Context) ([]ShareInfo, error) { iter := a.List(ctx) var err error var next ShareInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/sql/api.go b/service/sql/api.go index 52b77c792..128f20493 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -5,6 +5,7 @@ package sql import ( "context" + "errors" "fmt" "time" @@ -317,7 +318,7 @@ func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsReque seen := map[string]bool{} var err error var next Dashboard - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { id := next.Id if seen[id] { // item was added during iteration @@ -330,7 +331,7 @@ func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsReque break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -688,7 +689,7 @@ func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([ seen := map[string]bool{} var err error var next Query - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { id := next.Id if seen[id] { // item was added during iteration @@ -701,7 +702,7 @@ func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([ break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -844,7 +845,7 @@ func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryR iter := a.List(ctx, request) var err error var next QueryInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) totalCount++ @@ -852,7 +853,7 @@ func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryR break } } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -1446,11 +1447,11 @@ func (a *WarehousesAPI) ListAll(ctx context.Context, request ListWarehousesReque iter := a.List(ctx, request) var err error var next EndpointInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil diff --git a/service/sql/model.go b/service/sql/model.go index 8e2fc3298..d4db5f8a3 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -280,6 +280,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/workspace/api.go b/service/workspace/api.go index c0958a9f6..34c27e35d 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -5,6 +5,7 @@ package workspace import ( "context" + "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -114,11 +115,11 @@ func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, erro iter := a.List(ctx) var err error var next CredentialInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -332,11 +333,11 @@ func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]Rep iter := a.List(ctx, request) var err error var next RepoInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -576,11 +577,11 @@ func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ( iter := a.ListAcls(ctx, request) var err error var next AclItem - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -630,11 +631,11 @@ func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { iter := a.ListScopes(ctx) var err error var next SecretScope - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -674,11 +675,11 @@ func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequ iter := a.ListSecrets(ctx, request) var err error var next SecretMetadata - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil @@ -911,11 +912,11 @@ func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest iter := a.List(ctx, request) var err error var next ObjectInfo - for next, err = iter.Next(ctx); err != nil; next, err = iter.Next(ctx) { + for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { results = append(results, next) } - if err != listing.ErrNoMoreItems { + if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { return nil, err } return results, nil From 8ae4849e822d6e254ade95ac00cb1f48ae95ed3a Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 13:44:55 +0200 Subject: [PATCH 09/24] some fixes --- .codegen/accounts.go.tmpl | 1 + .codegen/api.go.tmpl | 31 +++--- .codegen/model.go.tmpl | 1 + .codegen/workspaces.go.tmpl | 1 + listing/listing.go | 126 ++++++++++++++++-------- listing/listing_test.go | 27 ++++- service/billing/api.go | 5 +- service/catalog/api.go | 80 +++++++-------- service/compute/api.go | 42 ++++---- service/files/api.go | 2 +- service/iam/api.go | 14 +-- service/iam/model.go | 4 +- service/jobs/api.go | 26 ++--- service/ml/api.go | 121 +++++++++-------------- service/ml/model_registry_usage_test.go | 12 +-- service/oauth2/api.go | 21 ++-- service/pipelines/api.go | 26 ++--- service/serving/api.go | 3 +- service/settings/api.go | 11 ++- service/sharing/api.go | 22 ++--- service/sql/api.go | 37 +++---- service/workspace/api.go | 25 +++-- 22 files changed, 330 insertions(+), 308 deletions(-) diff --git a/.codegen/accounts.go.tmpl b/.codegen/accounts.go.tmpl index e5fa3c9ba..2b3e1001f 100644 --- a/.codegen/accounts.go.tmpl +++ b/.codegen/accounts.go.tmpl @@ -3,6 +3,7 @@ package databricks import ( + "errors" "github.com/databricks/databricks-sdk-go/client" {{range .Packages}} "github.com/databricks/databricks-sdk-go/service/{{.Name}}" diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index d7dbd6780..a43fd2ce1 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -5,6 +5,7 @@ package {{.Name}} import ( "context" + "errors" "fmt" "time" "github.com/databricks/databricks-sdk-go/retries" @@ -164,6 +165,7 @@ 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}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) *listing.Iterator[{{if .Request}}{{.Request.PascalName}}{{else}}struct{}{{end}}, *{{ .Response.PascalName }}, {{template "type" .Pagination.Entity}}] { + {{ if not .Request }}request := struct{}{}{{end}} {{if eq .Pagination.Increment 1 -}} request.{{.Pagination.Offset.PascalName}} = 1 // start iterating from the first page {{end}} @@ -175,32 +177,31 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} return {{if .Pagination.Results}}resp.{{.Pagination.Results.PascalName}}{{else}}resp{{end}} } {{if .Pagination.MultiRequest -}} - getNextReq := func(resp *{{ .Response.PascalName }}) ({{.Request.PascalName}}, listing.ListingStatus) { - status := listing.ListingStatusCheckResult + getNextReq := func(resp *{{ .Response.PascalName }}) *{{.Request.PascalName}} { {{if .Pagination.Token -}} - request.{{.Pagination.Token.PollField.PascalName}} = resp.{{.Pagination.Token.Bind.PascalName}} if resp.{{.Pagination.Token.Bind.PascalName}} == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - {{- else if eq .Pagination.Increment 1 -}} - request.{{.Pagination.Offset.PascalName}} = resp.{{.Pagination.Offset.PascalName}} + 1 + request.{{.Pagination.Token.PollField.PascalName}} = resp.{{.Pagination.Token.Bind.PascalName}} {{- else if eq .Path "/api/2.0/clusters/events" -}} if resp.NextPage == nil { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted - request = *resp.NextPage + return nil } + request = *resp.NextPage + {{ else -}} + if len(getItems(resp)) == 0 { + return nil + } + {{ if eq .Pagination.Increment 1 -}} + request.{{.Pagination.Offset.PascalName}} = resp.{{.Pagination.Offset.PascalName}} + 1 {{- else -}} request.{{.Pagination.Offset.PascalName}} = resp.{{.Pagination.Offset.PascalName}} + {{template "type" .Pagination.Offset.Entity}}(len(resp.{{.Pagination.Results.PascalName}})) - {{- end}} - return request, status + {{- end}}{{ end }} + return &request } {{- end}} return listing.NewIterator( - {{if .Request}}request{{else}}struct{}{}{{end}}, + &request, getNextPage, getItems, {{if .Pagination.MultiRequest}}getNextReq{{else}}nil{{end}}) diff --git a/.codegen/model.go.tmpl b/.codegen/model.go.tmpl index b4ba91cd0..59458b938 100644 --- a/.codegen/model.go.tmpl +++ b/.codegen/model.go.tmpl @@ -5,6 +5,7 @@ package {{.Name}} import ( {{range .ImportedPackages}} "github.com/databricks/databricks-sdk-go/service/{{.}}"{{end}} + "fmt" "io" "github.com/databricks/databricks-sdk-go/marshal" ) diff --git a/.codegen/workspaces.go.tmpl b/.codegen/workspaces.go.tmpl index d7d261cdb..d964b4a8f 100644 --- a/.codegen/workspaces.go.tmpl +++ b/.codegen/workspaces.go.tmpl @@ -3,6 +3,7 @@ package databricks import ( + "errors" "github.com/databricks/databricks-sdk-go/client" {{range .Packages}} "github.com/databricks/databricks-sdk-go/service/{{.Name}}"{{end}} diff --git a/listing/listing.go b/listing/listing.go index 7d1615f0b..f58b77a52 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -5,24 +5,11 @@ import ( "errors" ) -type ListingStatus int - -const ( - // ListingStatusExhausted indicates that the iterator is exhausted and - // there are no more items to be fetched. - ListingStatusExhausted ListingStatus = iota - // ListingStatusNotExhausted indicates that the iterator is not exhausted - // and there are more items to be fetched. - ListingStatusNotExhausted - // ListingStatusCheckResult indicates that the iterator is exhausted if and - // only if there are no results returned. - ListingStatusCheckResult -) - // Use struct{} for Req to indicate one-shot iterator. type Iterator[Req, Resp, T any] struct { - // nextReq is the request to be used to fetch the next page. - nextReq Req + // nextReq is the request to be used to fetch the next page. If nil, then + // there is no next page to fetch. + nextReq *Req // getNextPage fetches the next page of items, returning the deserialized // response and error. @@ -32,8 +19,8 @@ type Iterator[Req, Resp, T any] struct { getItems func(Resp) []T // getNextReq is used to get the next request to be used in the next page. - // The ListingStatus value indicates whether the client can stop iterating. - getNextReq func(Resp) (Req, ListingStatus) + // If nil, then there is no next page to fetch. + getNextReq func(Resp) *Req // currentPage is the current page of items. currentPage []T @@ -41,17 +28,17 @@ type Iterator[Req, Resp, T any] struct { // currentPageIdx is the index of the next item from currentPage to return. currentPageIdx int - // isExhausted indicates whether there are no more items to be fetched. - isExhausted bool + // lastErr is the last error returned by getNextPage. + lastErr error } var ErrNoMoreItems = errors.New("no more items") func NewIterator[Req, Resp, T any]( - nextReq Req, + nextReq *Req, getNextPage func(context.Context, Req) (Resp, error), getItems func(Resp) []T, - getNextReq func(Resp) (Req, ListingStatus), + getNextReq func(Resp) *Req, ) *Iterator[Req, Resp, T] { return &Iterator[Req, Resp, T]{ nextReq: nextReq, @@ -65,26 +52,30 @@ func (i *Iterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error if i.currentPageIdx < len(i.currentPage) { return nil } - if i.isExhausted { - return ErrNoMoreItems - } - resp, err := i.getNextPage(ctx, i.nextReq) - if err != nil { - return err + if i.nextReq == nil { + i.currentPage = nil + i.currentPageIdx = 0 + return nil } - items := i.getItems(resp) - i.currentPage = items - i.currentPageIdx = 0 - var status ListingStatus - if i.getNextReq == nil { - status = ListingStatusExhausted - } else { - i.nextReq, status = i.getNextReq(resp) + if i.lastErr != nil { + return i.lastErr } - if !i.isExhausted && (status == ListingStatusExhausted || (status == ListingStatusCheckResult && len(items) == 0)) { - i.isExhausted = true + + // Keep loading pages while we have a next request and the current page is + // empty. + i.currentPage = nil + for i.nextReq != nil && len(i.currentPage) == 0 { + resp, err := i.getNextPage(ctx, *i.nextReq) + i.lastErr = err + if err != nil { + return err + } + items := i.getItems(resp) + i.currentPage = items + i.currentPageIdx = 0 + i.nextReq = i.getNextReq(resp) } - return err + return nil } func (i *Iterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { @@ -101,10 +92,61 @@ func (i *Iterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { return item, nil } -func (i *Iterator[Req, Resp, T]) HasNext(ctx context.Context) (bool, error) { +func (i *Iterator[Req, Resp, T]) HasNext(ctx context.Context) bool { err := i.loadNextPageIfNeeded(ctx) if err != nil { - return false, err + return true + } + return i.currentPageIdx < len(i.currentPage) +} + +type DedupeIterator[Req, Resp any, T comparable] struct { + it *Iterator[Req, Resp, T] + seen map[T]struct{} + current *T +} + +func NewDedupeIterator[Req, Resp any, T comparable]( + it *Iterator[Req, Resp, T]) *DedupeIterator[Req, Resp, T] { + return &DedupeIterator[Req, Resp, T]{ + it: it, + seen: make(map[T]struct{}), + } +} + +func (i *DedupeIterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { + if i.current != nil { + t := *i.current + i.current = nil + return t, nil + } + for { + t, err := i.it.Next(ctx) + if err != nil { + return t, err + } + if _, ok := i.seen[t]; !ok { + i.seen[t] = struct{}{} + return t, nil + } + } +} + +func (i *DedupeIterator[Req, Resp, T]) HasNext(ctx context.Context) bool { + if i.current != nil { + return true + } + for { + t, err := i.it.Next(ctx) + if errors.Is(err, ErrNoMoreItems) { + return false + } + if err != nil { + return true + } + if _, ok := i.seen[t]; !ok { + i.current = &t + return true + } } - return i.currentPageIdx < len(i.currentPage), nil } diff --git a/listing/listing_test.go b/listing/listing_test.go index 49d438c74..578333165 100644 --- a/listing/listing_test.go +++ b/listing/listing_test.go @@ -14,16 +14,18 @@ func TestIterator(t *testing.T) { } return []int{req, req + 1}, nil } - getNextReq := func(resp []int) (int, ListingStatus) { + getNextReq := func(resp []int) *int { if len(resp) == 0 { - return 0, ListingStatusExhausted + return nil } - return resp[len(resp)-1] + 1, ListingStatusCheckResult + x := resp[len(resp)-1] + 1 + return &x } getItems := func(resp []int) []int { return resp } - it := NewIterator(0, getNextPage, getItems, getNextReq) + x := 0 + it := NewIterator(&x, getNextPage, getItems, getNextReq) for i := 0; i < 10; i++ { v, err := it.Next(context.Background()) if err != nil { @@ -38,3 +40,20 @@ func TestIterator(t *testing.T) { t.Fatalf("expected %v, got %v", ErrNoMoreItems, err) } } + +// Tests to write: +// TestIterator_GetNextPageErrors tests that errors from getNextPage are propagated. + +// TestIterator_GetNextReqCheckResult tests that the iterator stops if there are no more items. + +// TestIterator_GetNextReqExhausted tests that the iterator stops even if some items are returned. + +// TestIterator_GetNextReqNotExhausted tests that the iterator continues if there are more items until CheckResult with no entries or Exhausted. + +// TestIterator_NextReturnsNextItem tests that Next returns the next item. + +// TestIterator_NextErrNoMoreItems tests that Next returns ErrNoMoreItems when there are no more items. + +// TestIterator_HasNextNoNext tests that HasNext returns false when there are no more items. + +// TestIterator_HasNextNext tests that HasNext returns true when there are more items. diff --git a/service/billing/api.go b/service/billing/api.go index c652d6e9b..60eb801cf 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -133,6 +133,7 @@ func (a *BudgetsAPI) GetByBudgetId(ctx context.Context, budgetId string) (*Wrapp // // This method is generated by Databricks SDK Code Generator. func (a *BudgetsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *BudgetList, BudgetWithStatus] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*BudgetList, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -143,7 +144,7 @@ func (a *BudgetsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *Budg } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -378,7 +379,7 @@ func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryReques } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) diff --git a/service/catalog/api.go b/service/catalog/api.go index e2de25631..3ba255fac 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -105,7 +105,7 @@ func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListA } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -217,6 +217,7 @@ func (a *AccountMetastoresAPI) GetByMetastoreId(ctx context.Context, metastoreId // // This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListMetastoresResponse, MetastoreInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -227,7 +228,7 @@ func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.Iterator[struc } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -562,6 +563,7 @@ func (a *CatalogsAPI) GetByName(ctx context.Context, name string) (*CatalogInfo, // // This method is generated by Databricks SDK Code Generator. func (a *CatalogsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListCatalogsResponse, CatalogInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListCatalogsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -572,7 +574,7 @@ func (a *CatalogsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *Lis } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -688,6 +690,7 @@ func (a *ConnectionsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Con // // This method is generated by Databricks SDK Code Generator. func (a *ConnectionsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListConnectionsResponse, ConnectionInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListConnectionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -698,7 +701,7 @@ func (a *ConnectionsAPI) List(ctx context.Context) *listing.Iterator[struct{}, * } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -875,6 +878,7 @@ func (a *ExternalLocationsAPI) GetByName(ctx context.Context, name string) (*Ext // // This method is generated by Databricks SDK Code Generator. func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListExternalLocationsResponse, ExternalLocationInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListExternalLocationsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -885,7 +889,7 @@ func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.Iterator[struc } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -1036,7 +1040,7 @@ func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) * } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -1286,6 +1290,7 @@ func (a *MetastoresAPI) GetById(ctx context.Context, id string) (*MetastoreInfo, // // This method is generated by Databricks SDK Code Generator. func (a *MetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListMetastoresResponse, MetastoreInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1296,7 +1301,7 @@ func (a *MetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *L } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -1554,18 +1559,15 @@ func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRe getItems := func(resp *ListModelVersionsResponse) []ModelVersionInfo { return resp.ModelVersions } - getNextReq := func(resp *ListModelVersionsResponse) (ListModelVersionsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListModelVersionsResponse) *ListModelVersionsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -1805,18 +1807,15 @@ func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredMo getItems := func(resp *ListRegisteredModelsResponse) []RegisteredModelInfo { return resp.RegisteredModels } - getNextReq := func(resp *ListRegisteredModelsResponse) (ListRegisteredModelsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListRegisteredModelsResponse) *ListRegisteredModelsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -2021,7 +2020,7 @@ func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *list } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -2200,6 +2199,7 @@ func (a *StorageCredentialsAPI) GetByName(ctx context.Context, name string) (*St // // This method is generated by Databricks SDK Code Generator. func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListStorageCredentialsResponse, StorageCredentialInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListStorageCredentialsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2210,7 +2210,7 @@ func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.Iterator[stru } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -2354,7 +2354,7 @@ func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRe } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -2575,18 +2575,15 @@ func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listin getItems := func(resp *ListTablesResponse) []TableInfo { return resp.Tables } - getNextReq := func(resp *ListTablesResponse) (ListTablesRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListTablesResponse) *ListTablesRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -2690,18 +2687,15 @@ func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequ getItems := func(resp *ListTableSummariesResponse) []TableSummary { return resp.Tables } - getNextReq := func(resp *ListTableSummariesResponse) (ListSummariesRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListTableSummariesResponse) *ListSummariesRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -2849,7 +2843,7 @@ func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *list } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) diff --git a/service/compute/api.go b/service/compute/api.go index 6a949cdec..c96f1ae68 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -166,7 +166,7 @@ func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPolici } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -618,18 +618,16 @@ func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.It getItems := func(resp *GetEventsResponse) []ClusterEvent { return resp.Events } - getNextReq := func(resp *GetEventsResponse) (GetEvents, listing.ListingStatus) { - status := listing.ListingStatusCheckResult + getNextReq := func(resp *GetEventsResponse) *GetEvents { if resp.NextPage == nil { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted - request = *resp.NextPage + return nil } - return request, status + request = *resp.NextPage + + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -732,7 +730,7 @@ func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *li } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -1560,6 +1558,7 @@ func (a *GlobalInitScriptsAPI) GetByScriptId(ctx context.Context, scriptId strin // // This method is generated by Databricks SDK Code Generator. func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListGlobalInitScriptsResponse, GlobalInitScriptDetails] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListGlobalInitScriptsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1570,7 +1569,7 @@ func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.Iterator[struc } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -1784,6 +1783,7 @@ func (a *InstancePoolsAPI) GetPermissionsByInstancePoolId(ctx context.Context, i // // This method is generated by Databricks SDK Code Generator. func (a *InstancePoolsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListInstancePools, InstancePoolAndStats] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListInstancePools, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1794,7 +1794,7 @@ func (a *InstancePoolsAPI) List(ctx context.Context) *listing.Iterator[struct{}, } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -1953,6 +1953,7 @@ func (a *InstanceProfilesAPI) Edit(ctx context.Context, request InstanceProfile) // // This method is generated by Databricks SDK Code Generator. func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListInstanceProfilesResponse, InstanceProfile] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListInstanceProfilesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1963,7 +1964,7 @@ func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.Iterator[struct } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -2092,7 +2093,7 @@ func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusR } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -2222,18 +2223,15 @@ func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamilies getItems := func(resp *ListPolicyFamiliesResponse) []PolicyFamily { return resp.PolicyFamilies } - getNextReq := func(resp *ListPolicyFamiliesResponse) (ListPolicyFamiliesRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListPolicyFamiliesResponse) *ListPolicyFamiliesRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) diff --git a/service/files/api.go b/service/files/api.go index 1cf6a673e..caad67a3b 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -154,7 +154,7 @@ func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.It } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) diff --git a/service/iam/api.go b/service/iam/api.go index 54a388478..077fb8bc8 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -215,7 +215,7 @@ func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRe } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -392,7 +392,7 @@ func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAcco } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -578,7 +578,7 @@ func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequ } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -791,7 +791,7 @@ func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listin } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -1093,7 +1093,7 @@ func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrin } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -1294,7 +1294,7 @@ func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing. } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -1481,7 +1481,7 @@ func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspace } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) diff --git a/service/iam/model.go b/service/iam/model.go index e65f2492f..d574aee29 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,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. @@ -1024,7 +1024,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty" url:"-"` + Id string `json:"id,omitempty"` Roles []ComplexValue `json:"roles,omitempty"` diff --git a/service/jobs/api.go b/service/jobs/api.go index 72217f0af..938f0ed0c 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -338,18 +338,15 @@ func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.It getItems := func(resp *ListJobsResponse) []BaseJob { return resp.Jobs } - getNextReq := func(resp *ListJobsResponse) (ListJobsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListJobsResponse) *ListJobsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -443,18 +440,15 @@ func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listin getItems := func(resp *ListRunsResponse) []BaseRun { return resp.Runs } - getNextReq := func(resp *ListRunsResponse) (ListRunsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListRunsResponse) *ListRunsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) diff --git a/service/ml/api.go b/service/ml/api.go index baf207f9e..e3e71dd5e 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -137,18 +137,15 @@ func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryReque getItems := func(resp *GetMetricHistoryResponse) []Metric { return resp.Metrics } - getNextReq := func(resp *GetMetricHistoryResponse) (GetHistoryRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *GetMetricHistoryResponse) *GetHistoryRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -236,18 +233,15 @@ func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifact getItems := func(resp *ListArtifactsResponse) []FileInfo { return resp.Files } - getNextReq := func(resp *ListArtifactsResponse) (ListArtifactsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListArtifactsResponse) *ListArtifactsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -282,18 +276,15 @@ func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperi getItems := func(resp *ListExperimentsResponse) []Experiment { return resp.Experiments } - getNextReq := func(resp *ListExperimentsResponse) (ListExperimentsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListExperimentsResponse) *ListExperimentsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -439,18 +430,15 @@ func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchEx getItems := func(resp *SearchExperimentsResponse) []Experiment { return resp.Experiments } - getNextReq := func(resp *SearchExperimentsResponse) (SearchExperiments, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *SearchExperimentsResponse) *SearchExperiments { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -487,18 +475,15 @@ func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *li getItems := func(resp *SearchRunsResponse) []Run { return resp.Runs } - getNextReq := func(resp *SearchRunsResponse) (SearchRuns, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *SearchRunsResponse) *SearchRuns { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -709,7 +694,7 @@ func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLat } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -804,18 +789,15 @@ func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsReq getItems := func(resp *ListModelsResponse) []Model { return resp.RegisteredModels } - getNextReq := func(resp *ListModelsResponse) (ListModelsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListModelsResponse) *ListModelsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -858,7 +840,7 @@ func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request L } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -895,18 +877,15 @@ func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhook getItems := func(resp *ListRegistryWebhooks) []RegistryWebhook { return resp.Webhooks } - getNextReq := func(resp *ListRegistryWebhooks) (ListWebhooksRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListRegistryWebhooks) *ListWebhooksRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -955,18 +934,15 @@ func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request Sear getItems := func(resp *SearchModelVersionsResponse) []ModelVersion { return resp.ModelVersions } - getNextReq := func(resp *SearchModelVersionsResponse) (SearchModelVersionsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *SearchModelVersionsResponse) *SearchModelVersionsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -1007,18 +983,15 @@ func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModel getItems := func(resp *SearchModelsResponse) []Model { return resp.RegisteredModels } - getNextReq := func(resp *SearchModelsResponse) (SearchModelsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *SearchModelsResponse) *SearchModelsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index b5ccf9028..7199cd404 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -109,7 +109,7 @@ func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -124,18 +124,18 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { } logger.Infof(ctx, "found %v", model) - mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", mv) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -150,14 +150,14 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { } logger.Infof(ctx, "found %v", model) - created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", mv) } diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 3386d9059..230887fa5 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -92,6 +92,7 @@ func (a *CustomAppIntegrationAPI) GetByIntegrationId(ctx context.Context, integr // // This method is generated by Databricks SDK Code Generator. func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetCustomAppIntegrationsOutput, GetCustomAppIntegrationOutput] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetCustomAppIntegrationsOutput, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -102,7 +103,7 @@ func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[st } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -231,18 +232,15 @@ func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPubli getItems := func(resp *GetPublishedAppsOutput) []PublishedAppOutput { return resp.Apps } - getNextReq := func(resp *GetPublishedAppsOutput) (ListOAuthPublishedAppsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *GetPublishedAppsOutput) *ListOAuthPublishedAppsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -349,6 +347,7 @@ func (a *PublishedAppIntegrationAPI) GetByIntegrationId(ctx context.Context, int // // This method is generated by Databricks SDK Code Generator. func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetPublishedAppIntegrationsOutput, GetPublishedAppIntegrationOutput] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetPublishedAppIntegrationsOutput, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -359,7 +358,7 @@ func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.Iterator } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -469,7 +468,7 @@ func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServi } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 696575635..25302b647 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -264,18 +264,15 @@ func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipel getItems := func(resp *ListPipelineEventsResponse) []PipelineEvent { return resp.Events } - getNextReq := func(resp *ListPipelineEventsResponse) (ListPipelineEventsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListPipelineEventsResponse) *ListPipelineEventsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -325,18 +322,15 @@ func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesR getItems := func(resp *ListPipelinesResponse) []PipelineStateInfo { return resp.Statuses } - getNextReq := func(resp *ListPipelinesResponse) (ListPipelinesRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListPipelinesResponse) *ListPipelinesRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) diff --git a/service/serving/api.go b/service/serving/api.go index d72013e85..0acc54693 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -255,6 +255,7 @@ func (a *ServingEndpointsAPI) GetPermissionsByServingEndpointId(ctx context.Cont // // This method is generated by Databricks SDK Code Generator. func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListEndpointsResponse, ServingEndpoint] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListEndpointsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -265,7 +266,7 @@ func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.Iterator[struct } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) diff --git a/service/settings/api.go b/service/settings/api.go index 906587000..197b968c0 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -119,6 +119,7 @@ func (a *AccountIpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAcc // // This method is generated by Databricks SDK Code Generator. func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetIpAccessListsResponse, IpAccessListInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetIpAccessListsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -129,7 +130,7 @@ func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.Iterator[st } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -439,6 +440,7 @@ func (a *IpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAccessList // // This method is generated by Databricks SDK Code Generator. func (a *IpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListIpAccessListResponse, IpAccessListInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListIpAccessListResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -449,7 +451,7 @@ func (a *IpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -715,7 +717,7 @@ func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManageme } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -871,6 +873,7 @@ func (a *TokensAPI) DeleteByTokenId(ctx context.Context, tokenId string) error { // // This method is generated by Databricks SDK Code Generator. func (a *TokensAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListTokensResponse, TokenInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListTokensResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -881,7 +884,7 @@ func (a *TokensAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListT } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) diff --git a/service/sharing/api.go b/service/sharing/api.go index ded51dfdd..6d930cf60 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -106,18 +106,15 @@ func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) getItems := func(resp *ListCleanRoomsResponse) []CleanRoomInfo { return resp.CleanRooms } - getNextReq := func(resp *ListCleanRoomsResponse) (ListCleanRoomsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListCleanRoomsResponse) *ListCleanRoomsRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -259,7 +256,7 @@ func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) * } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -323,7 +320,7 @@ func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -544,7 +541,7 @@ func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -710,6 +707,7 @@ func (a *SharesAPI) GetByName(ctx context.Context, name string) (*ShareInfo, err // // This method is generated by Databricks SDK Code Generator. func (a *SharesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListSharesResponse, ShareInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListSharesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -720,7 +718,7 @@ func (a *SharesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListS } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) diff --git a/service/sql/api.go b/service/sql/api.go index 128f20493..fc345f7f1 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -288,6 +288,7 @@ func (a *DashboardsAPI) GetByDashboardId(ctx context.Context, dashboardId string // // This method is generated by Databricks SDK Code Generator. func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) *listing.Iterator[ListDashboardsRequest, *ListResponse, Dashboard] { + request.Page = 1 // start iterating from the first page getNextPage := func(ctx context.Context, req ListDashboardsRequest) (*ListResponse, error) { @@ -297,13 +298,15 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) getItems := func(resp *ListResponse) []Dashboard { return resp.Results } - getNextReq := func(resp *ListResponse) (ListDashboardsRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult + getNextReq := func(resp *ListResponse) *ListDashboardsRequest { + if len(getItems(resp)) == 0 { + return nil + } request.Page = resp.Page + 1 - return request, status + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -659,6 +662,7 @@ func (a *QueriesAPI) GetByQueryId(ctx context.Context, queryId string) (*Query, // // This method is generated by Databricks SDK Code Generator. func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *listing.Iterator[ListQueriesRequest, *QueryList, Query] { + request.Page = 1 // start iterating from the first page getNextPage := func(ctx context.Context, req ListQueriesRequest) (*QueryList, error) { @@ -668,13 +672,15 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *list getItems := func(resp *QueryList) []Query { return resp.Results } - getNextReq := func(resp *QueryList) (ListQueriesRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult + getNextReq := func(resp *QueryList) *ListQueriesRequest { + if len(getItems(resp)) == 0 { + return nil + } request.Page = resp.Page + 1 - return request, status + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -821,18 +827,15 @@ func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequ getItems := func(resp *ListQueriesResponse) []QueryInfo { return resp.Res } - getNextReq := func(resp *ListQueriesResponse) (ListQueryHistoryRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.PageToken = resp.NextPageToken + getNextReq := func(resp *ListQueriesResponse) *ListQueryHistoryRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.PageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -1436,7 +1439,7 @@ func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) diff --git a/service/workspace/api.go b/service/workspace/api.go index 34c27e35d..540aca781 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -94,6 +94,7 @@ func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId // // This method is generated by Databricks SDK Code Generator. func (a *GitCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetCredentialsResponse, CredentialInfo] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetCredentialsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -104,7 +105,7 @@ func (a *GitCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{} } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -311,18 +312,15 @@ func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing. getItems := func(resp *ListReposResponse) []RepoInfo { return resp.Repos } - getNextReq := func(resp *ListReposResponse) (ListReposRequest, listing.ListingStatus) { - status := listing.ListingStatusCheckResult - request.NextPageToken = resp.NextPageToken + getNextReq := func(resp *ListReposResponse) *ListReposRequest { if resp.NextPageToken == "" { - status = listing.ListingStatusExhausted - } else { - status = listing.ListingStatusNotExhausted + return nil } - return request, status + request.NextPageToken = resp.NextPageToken + return &request } return listing.NewIterator( - request, + &request, getNextPage, getItems, getNextReq) @@ -566,7 +564,7 @@ func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *lis } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -610,6 +608,7 @@ func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAc // // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.Iterator[struct{}, *ListScopesResponse, SecretScope] { + request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListScopesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -620,7 +619,7 @@ func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.Iterator[struct{}, } return listing.NewIterator( - struct{}{}, + &request, getNextPage, getItems, nil) @@ -664,7 +663,7 @@ func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) @@ -901,7 +900,7 @@ func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) * } return listing.NewIterator( - request, + &request, getNextPage, getItems, nil) From f29ef2b845245288e4d27d4a9a81ec917d901224 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 15:44:44 +0200 Subject: [PATCH 10/24] more tweaks --- .codegen/api.go.tmpl | 33 ++- listing/listing.go | 47 ++-- listing/listing_test.go | 229 ++++++++++++++++---- service/billing/api.go | 37 ++-- service/catalog/api.go | 271 ++++++++++++------------ service/compute/api.go | 145 +++++++------ service/files/api.go | 19 +- service/iam/api.go | 127 ++++++----- service/iam/model.go | 2 +- service/jobs/api.go | 37 ++-- service/ml/api.go | 199 +++++++++-------- service/ml/model_registry_usage_test.go | 26 +-- service/oauth2/api.go | 73 ++++--- service/pipelines/api.go | 37 ++-- service/serving/api.go | 19 +- service/settings/api.go | 73 ++++--- service/sharing/api.go | 91 ++++---- service/sql/api.go | 91 ++++---- service/workspace/api.go | 109 +++++----- 19 files changed, 897 insertions(+), 768 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index a43fd2ce1..54102f6f0 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -164,7 +164,7 @@ func (a *{{.Service.Name}}API) {{.PascalName}}AndWait(ctx context.Context{{if .R {{.Comment "// " 80}} // // This method is generated by Databricks SDK Code Generator. -func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) *listing.Iterator[{{if .Request}}{{.Request.PascalName}}{{else}}struct{}{{end}}, *{{ .Response.PascalName }}, {{template "type" .Pagination.Entity}}] { +func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) (it listing.Iterator[{{template "type" .Pagination.Entity}}]) { {{ if not .Request }}request := struct{}{}{{end}} {{if eq .Pagination.Increment 1 -}} request.{{.Pagination.Offset.PascalName}} = 1 // start iterating from the first page @@ -200,11 +200,19 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} return &request } {{- end}} - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, {{if .Pagination.MultiRequest}}getNextReq{{else}}nil{{end}}) + {{ if .NeedsOffsetDedupe -}} + it = listing.NewDedupeIterator( + it, + func(item {{ template "type" .Pagination.Entity }}) {{ template "type" .IdentifierField.Entity }} { + return item{{ template "field-path" .IdFieldPath }} + }) + {{- end }} + return it } func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{ template "type" .Pagination.Entity }}, error) { @@ -214,21 +222,11 @@ func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Reque limit := request.{{.Pagination.Limit.PascalName}} {{ end -}} iter := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) - {{if .NeedsOffsetDedupe -}} - // deduplicate items that may have been added during iteration - seen := map[{{template "type" .IdentifierField.Entity}}]bool{} - {{end -}} - var err error - var next {{ template "type" .Pagination.Entity }} - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - {{ if .NeedsOffsetDedupe -}} - id := next{{ template "field-path" .IdFieldPath }} - if seen[id] { - // item was added during iteration - continue + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err } - seen[id] = true - {{- end}} results = append(results, next) {{ if .Pagination.Limit -}} totalCount++ @@ -237,9 +235,6 @@ func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Reque } {{- end -}} } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } {{end}}{{if .NamedIdMap}} diff --git a/listing/listing.go b/listing/listing.go index f58b77a52..b7d8c8873 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -5,8 +5,13 @@ import ( "errors" ) +type Iterator[T any] interface { + HasNext(context.Context) bool + Next(context.Context) (T, error) +} + // Use struct{} for Req to indicate one-shot iterator. -type Iterator[Req, Resp, T any] struct { +type IteratorImpl[Req, Resp, T any] struct { // nextReq is the request to be used to fetch the next page. If nil, then // there is no next page to fetch. nextReq *Req @@ -39,8 +44,8 @@ func NewIterator[Req, Resp, T any]( getNextPage func(context.Context, Req) (Resp, error), getItems func(Resp) []T, getNextReq func(Resp) *Req, -) *Iterator[Req, Resp, T] { - return &Iterator[Req, Resp, T]{ +) *IteratorImpl[Req, Resp, T] { + return &IteratorImpl[Req, Resp, T]{ nextReq: nextReq, getNextPage: getNextPage, getItems: getItems, @@ -48,7 +53,7 @@ func NewIterator[Req, Resp, T any]( } } -func (i *Iterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error { +func (i *IteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error { if i.currentPageIdx < len(i.currentPage) { return nil } @@ -78,7 +83,7 @@ func (i *Iterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error return nil } -func (i *Iterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { +func (i *IteratorImpl[Req, Resp, T]) Next(ctx context.Context) (T, error) { var t T err := i.loadNextPageIfNeeded(ctx) if err != nil { @@ -92,7 +97,7 @@ func (i *Iterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { return item, nil } -func (i *Iterator[Req, Resp, T]) HasNext(ctx context.Context) bool { +func (i *IteratorImpl[Req, Resp, T]) HasNext(ctx context.Context) bool { err := i.loadNextPageIfNeeded(ctx) if err != nil { return true @@ -100,21 +105,22 @@ func (i *Iterator[Req, Resp, T]) HasNext(ctx context.Context) bool { return i.currentPageIdx < len(i.currentPage) } -type DedupeIterator[Req, Resp any, T comparable] struct { - it *Iterator[Req, Resp, T] - seen map[T]struct{} +type DedupeIteratorImpl[T any, Id comparable] struct { + it Iterator[T] + getId func(T) Id + seen map[Id]struct{} current *T } -func NewDedupeIterator[Req, Resp any, T comparable]( - it *Iterator[Req, Resp, T]) *DedupeIterator[Req, Resp, T] { - return &DedupeIterator[Req, Resp, T]{ - it: it, - seen: make(map[T]struct{}), +func NewDedupeIterator[T any, Id comparable](it Iterator[T], getId func(T) Id) *DedupeIteratorImpl[T, Id] { + return &DedupeIteratorImpl[T, Id]{ + it: it, + getId: getId, + seen: make(map[Id]struct{}), } } -func (i *DedupeIterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { +func (i *DedupeIteratorImpl[T, Id]) Next(ctx context.Context) (T, error) { if i.current != nil { t := *i.current i.current = nil @@ -125,14 +131,15 @@ func (i *DedupeIterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { if err != nil { return t, err } - if _, ok := i.seen[t]; !ok { - i.seen[t] = struct{}{} + id := i.getId(t) + if _, ok := i.seen[id]; !ok { + i.seen[id] = struct{}{} return t, nil } } } -func (i *DedupeIterator[Req, Resp, T]) HasNext(ctx context.Context) bool { +func (i *DedupeIteratorImpl[T, Id]) HasNext(ctx context.Context) bool { if i.current != nil { return true } @@ -144,8 +151,10 @@ func (i *DedupeIterator[Req, Resp, T]) HasNext(ctx context.Context) bool { if err != nil { return true } - if _, ok := i.seen[t]; !ok { + id := i.getId(t) + if _, ok := i.seen[id]; !ok { i.current = &t + i.seen[id] = struct{}{} return true } } diff --git a/listing/listing_test.go b/listing/listing_test.go index 578333165..2d3d178c6 100644 --- a/listing/listing_test.go +++ b/listing/listing_test.go @@ -1,59 +1,204 @@ -package listing +package listing_test import ( "context" "errors" "testing" + + "github.com/databricks/databricks-sdk-go/listing" + "github.com/stretchr/testify/assert" ) -// TestIterator tests the Iterator type. func TestIterator(t *testing.T) { - getNextPage := func(ctx context.Context, req int) ([]int, error) { - if req >= 10 { - return nil, nil - } - return []int{req, req + 1}, nil - } - getNextReq := func(resp []int) *int { - if len(resp) == 0 { - return nil - } - x := resp[len(resp)-1] + 1 - return &x - } - getItems := func(resp []int) []int { - return resp - } - x := 0 - it := NewIterator(&x, getNextPage, getItems, getNextReq) - for i := 0; i < 10; i++ { - v, err := it.Next(context.Background()) - if err != nil { - t.Fatal(err) - } - if v != i { - t.Fatalf("expected %d, got %d", i, v) - } - } - _, err := it.Next(context.Background()) - if !errors.Is(err, ErrNoMoreItems) { - t.Fatalf("expected %v, got %v", ErrNoMoreItems, err) - } + t.Run("basic iteration", func(t *testing.T) { + reqs := []string{"page1", "page2", "page3"} + pages := map[string]map[string][]int{ + "page1": {"page": {1, 2}}, + "page2": {"page": {3, 4}}, + "page3": {"page": {5, 6}}, + } + nextReq := "page1" + + iterator := listing.NewIterator(&nextReq, + func(ctx context.Context, req string) (map[string][]int, error) { + return pages[req], nil + }, + func(resp map[string][]int) []int { + return resp["page"] + }, + func(resp map[string][]int) *string { + for i, r := range reqs { + if r == nextReq && i+1 < len(reqs) { + nextReq = reqs[i+1] + return &nextReq + } + } + return nil + }, + ) + + for i := 1; i <= 6; i++ { + item, err := iterator.Next(context.Background()) + assert.NoError(t, err) + assert.Equal(t, i, item) + } + + _, err := iterator.Next(context.Background()) + assert.ErrorIs(t, err, listing.ErrNoMoreItems) + }) + + t.Run("error propagation", func(t *testing.T) { + expectedErr := errors.New("some error") + iterator := listing.NewIterator[struct{}, []int, struct{}](&struct{}{}, + func(ctx context.Context, req struct{}) ([]int, error) { + return nil, expectedErr + }, + nil, + nil, + ) + + _, err := iterator.Next(context.Background()) + assert.ErrorIs(t, err, expectedErr) + }) + + t.Run("error propagation from HasNext", func(t *testing.T) { + expectedErr := errors.New("some error") + iterator := listing.NewIterator[struct{}, []int, struct{}](&struct{}{}, + func(ctx context.Context, req struct{}) ([]int, error) { + return nil, expectedErr + }, + nil, + nil, + ) + + b := iterator.HasNext(context.Background()) + assert.True(t, b) + // Error from HasNext is stored and returned on call to Next + _, err := iterator.Next(context.Background()) + assert.ErrorIs(t, err, expectedErr) + // Error is cached + _, err2 := iterator.Next(context.Background()) + assert.Equal(t, err, err2) + }) + + t.Run("iteration with empty page in the middle", func(t *testing.T) { + reqs := []string{"page1", "page2", "page3"} + pages := map[string]map[string][]int{ + "page1": {"page": {1, 2}}, + "page2": {"page": {}}, + "page3": {"page": {3, 4}}, + } + nextReq := "page1" + + iterator := listing.NewIterator(&nextReq, + func(ctx context.Context, req string) (map[string][]int, error) { + return pages[req], nil + }, + func(resp map[string][]int) []int { + return resp["page"] + }, + func(resp map[string][]int) *string { + for i, r := range reqs { + if r == nextReq && i+1 < len(reqs) { + nextReq = reqs[i+1] + return &nextReq + } + } + return nil + }, + ) + + for i := 1; i <= 4; i++ { + item, err := iterator.Next(context.Background()) + assert.NoError(t, err) + assert.Equal(t, i, item) + } + + _, err := iterator.Next(context.Background()) + assert.ErrorIs(t, err, listing.ErrNoMoreItems) + }) } -// Tests to write: -// TestIterator_GetNextPageErrors tests that errors from getNextPage are propagated. +func TestDedupeIterator(t *testing.T) { + t.Run("basic iteration", func(t *testing.T) { + reqs := []string{"page1", "page2", "page3"} + pages := map[string][]int{ + "page1": {1, 2, 2}, + "page2": {3, 4, 4}, + "page3": {5, 5, 6}, + } + nextReq := "page1" -// TestIterator_GetNextReqCheckResult tests that the iterator stops if there are no more items. + iterator := listing.NewIterator(&nextReq, + func(ctx context.Context, req string) ([]int, error) { + return pages[req], nil + }, + func(resp []int) []int { + return resp + }, + func(resp []int) *string { + for i, r := range reqs { + if r == nextReq && i+1 < len(reqs) { + nextReq = reqs[i+1] + return &nextReq + } + } + return nil + }, + ) -// TestIterator_GetNextReqExhausted tests that the iterator stops even if some items are returned. + dedupeIterator := listing.NewDedupeIterator( + iterator, func(a int) int { return a }) -// TestIterator_GetNextReqNotExhausted tests that the iterator continues if there are more items until CheckResult with no entries or Exhausted. + for i := 1; i <= 6; i++ { + item, err := dedupeIterator.Next(context.Background()) + assert.NoError(t, err) + assert.Equal(t, i, item) + } -// TestIterator_NextReturnsNextItem tests that Next returns the next item. + _, err := dedupeIterator.Next(context.Background()) + assert.ErrorIs(t, err, listing.ErrNoMoreItems) + }) -// TestIterator_NextErrNoMoreItems tests that Next returns ErrNoMoreItems when there are no more items. + t.Run("HasNext caches appropriately", func(t *testing.T) { + reqs := []string{"page1", "page2", "page3"} + pages := map[string][]int{ + "page1": {1, 2, 2}, + "page2": {3, 4, 4}, + "page3": {5, 5, 6}, + } + nextReq := "page1" + + iterator := listing.NewIterator(&nextReq, + func(ctx context.Context, req string) ([]int, error) { + return pages[req], nil + }, + func(resp []int) []int { + return resp + }, + func(resp []int) *string { + for i, r := range reqs { + if r == nextReq && i+1 < len(reqs) { + nextReq = reqs[i+1] + return &nextReq + } + } + return nil + }, + ) -// TestIterator_HasNextNoNext tests that HasNext returns false when there are no more items. + dedupeIterator := listing.NewDedupeIterator( + iterator, func(a int) int { return a }) + values := make([]int, 0) + for dedupeIterator.HasNext(context.Background()) { + v, err := dedupeIterator.Next(context.Background()) + values = append(values, v) + assert.NoError(t, err) + } + assert.Equal(t, []int{1, 2, 3, 4, 5, 6}, values) + }) -// TestIterator_HasNextNext tests that HasNext returns true when there are more items. + t.Run("HasNext returns true when there is an error", func(t *testing.T) { + + }) +} diff --git a/service/billing/api.go b/service/billing/api.go index 60eb801cf..3b8794bb8 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -5,7 +5,6 @@ package billing import ( "context" - "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -132,7 +131,7 @@ func (a *BudgetsAPI) GetByBudgetId(ctx context.Context, budgetId string) (*Wrapp // for each day that the budget is configured to include. // // This method is generated by Databricks SDK Code Generator. -func (a *BudgetsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *BudgetList, BudgetWithStatus] { +func (a *BudgetsAPI) List(ctx context.Context) (it listing.Iterator[BudgetWithStatus]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*BudgetList, error) { @@ -143,25 +142,25 @@ func (a *BudgetsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *Budg return resp.Budgets } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { var results []BudgetWithStatus iter := a.List(ctx) - var err error - var next BudgetWithStatus - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -368,7 +367,7 @@ func (a *LogDeliveryAPI) GetByLogDeliveryConfigurationId(ctx context.Context, lo // specified by ID. // // This method is generated by Databricks SDK Code Generator. -func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryRequest) *listing.Iterator[ListLogDeliveryRequest, *WrappedLogDeliveryConfigurations, LogDeliveryConfiguration] { +func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryRequest) (it listing.Iterator[LogDeliveryConfiguration]) { getNextPage := func(ctx context.Context, req ListLogDeliveryRequest) (*WrappedLogDeliveryConfigurations, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -378,25 +377,25 @@ func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryReques return resp.LogDeliveryConfigurations } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *LogDeliveryAPI) ListAll(ctx context.Context, request ListLogDeliveryRequest) ([]LogDeliveryConfiguration, error) { var results []LogDeliveryConfiguration iter := a.List(ctx, request) - var err error - var next LogDeliveryConfiguration - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/catalog/api.go b/service/catalog/api.go index 3ba255fac..3694b2910 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -5,7 +5,6 @@ package catalog import ( "context" - "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -94,7 +93,7 @@ func (a *AccountMetastoreAssignmentsAPI) GetByWorkspaceId(ctx context.Context, w // metastore. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) *listing.Iterator[ListAccountMetastoreAssignmentsRequest, *ListAccountMetastoreAssignmentsResponse, int64] { +func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) (it listing.Iterator[int64]) { getNextPage := func(ctx context.Context, req ListAccountMetastoreAssignmentsRequest) (*ListAccountMetastoreAssignmentsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -104,25 +103,25 @@ func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListA return resp.WorkspaceIds } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *AccountMetastoreAssignmentsAPI) ListAll(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) ([]int64, error) { var results []int64 iter := a.List(ctx, request) - var err error - var next int64 - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -216,7 +215,7 @@ func (a *AccountMetastoresAPI) GetByMetastoreId(ctx context.Context, metastoreId // Gets all Unity Catalog metastores associated with an account specified by ID. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListMetastoresResponse, MetastoreInfo] { +func (a *AccountMetastoresAPI) List(ctx context.Context) (it listing.Iterator[MetastoreInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { @@ -227,25 +226,25 @@ func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.Iterator[struc return resp.Metastores } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *AccountMetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { var results []MetastoreInfo iter := a.List(ctx) - var err error - var next MetastoreInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -562,7 +561,7 @@ func (a *CatalogsAPI) GetByName(ctx context.Context, name string) (*CatalogInfo, // the array. // // This method is generated by Databricks SDK Code Generator. -func (a *CatalogsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListCatalogsResponse, CatalogInfo] { +func (a *CatalogsAPI) List(ctx context.Context) (it listing.Iterator[CatalogInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListCatalogsResponse, error) { @@ -573,25 +572,25 @@ func (a *CatalogsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *Lis return resp.Catalogs } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *CatalogsAPI) ListAll(ctx context.Context) ([]CatalogInfo, error) { var results []CatalogInfo iter := a.List(ctx) - var err error - var next CatalogInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -689,7 +688,7 @@ func (a *ConnectionsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Con // List all connections. // // This method is generated by Databricks SDK Code Generator. -func (a *ConnectionsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListConnectionsResponse, ConnectionInfo] { +func (a *ConnectionsAPI) List(ctx context.Context) (it listing.Iterator[ConnectionInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListConnectionsResponse, error) { @@ -700,25 +699,25 @@ func (a *ConnectionsAPI) List(ctx context.Context) *listing.Iterator[struct{}, * return resp.Connections } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ConnectionsAPI) ListAll(ctx context.Context) ([]ConnectionInfo, error) { var results []ConnectionInfo iter := a.List(ctx) - var err error - var next ConnectionInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -877,7 +876,7 @@ func (a *ExternalLocationsAPI) GetByName(ctx context.Context, name string) (*Ext // array. // // This method is generated by Databricks SDK Code Generator. -func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListExternalLocationsResponse, ExternalLocationInfo] { +func (a *ExternalLocationsAPI) List(ctx context.Context) (it listing.Iterator[ExternalLocationInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListExternalLocationsResponse, error) { @@ -888,25 +887,25 @@ func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.Iterator[struc return resp.ExternalLocations } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ExternalLocationsAPI) ListAll(ctx context.Context) ([]ExternalLocationInfo, error) { var results []ExternalLocationInfo iter := a.List(ctx) - var err error - var next ExternalLocationInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1029,7 +1028,7 @@ func (a *FunctionsAPI) GetByName(ctx context.Context, name string) (*FunctionInf // the array. // // This method is generated by Databricks SDK Code Generator. -func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) *listing.Iterator[ListFunctionsRequest, *ListFunctionsResponse, FunctionInfo] { +func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) (it listing.Iterator[FunctionInfo]) { getNextPage := func(ctx context.Context, req ListFunctionsRequest) (*ListFunctionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1039,25 +1038,25 @@ func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) * return resp.Functions } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *FunctionsAPI) ListAll(ctx context.Context, request ListFunctionsRequest) ([]FunctionInfo, error) { var results []FunctionInfo iter := a.List(ctx, request) - var err error - var next FunctionInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1289,7 +1288,7 @@ func (a *MetastoresAPI) GetById(ctx context.Context, id string) (*MetastoreInfo, // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *MetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListMetastoresResponse, MetastoreInfo] { +func (a *MetastoresAPI) List(ctx context.Context) (it listing.Iterator[MetastoreInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { @@ -1300,25 +1299,25 @@ func (a *MetastoresAPI) List(ctx context.Context) *listing.Iterator[struct{}, *L return resp.Metastores } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *MetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { var results []MetastoreInfo iter := a.List(ctx) - var err error - var next MetastoreInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1550,7 +1549,7 @@ func (a *ModelVersionsAPI) GetByAliasByFullNameAndAlias(ctx context.Context, ful // There is no guarantee of a specific ordering of the elements in the response. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRequest) *listing.Iterator[ListModelVersionsRequest, *ListModelVersionsResponse, ModelVersionInfo] { +func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRequest) (it listing.Iterator[ModelVersionInfo]) { getNextPage := func(ctx context.Context, req ListModelVersionsRequest) (*ListModelVersionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1566,11 +1565,13 @@ func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRe request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersionsRequest) ([]ModelVersionInfo, error) { @@ -1578,19 +1579,17 @@ func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersion var totalCount int = 0 limit := request.MaxResults iter := a.List(ctx, request) - var err error - var next ModelVersionInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1798,7 +1797,7 @@ func (a *RegisteredModelsAPI) GetByFullName(ctx context.Context, fullName string // There is no guarantee of a specific ordering of the elements in the response. // // This method is generated by Databricks SDK Code Generator. -func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) *listing.Iterator[ListRegisteredModelsRequest, *ListRegisteredModelsResponse, RegisteredModelInfo] { +func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) (it listing.Iterator[RegisteredModelInfo]) { getNextPage := func(ctx context.Context, req ListRegisteredModelsRequest) (*ListRegisteredModelsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1814,11 +1813,13 @@ func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredMo request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegisteredModelsRequest) ([]RegisteredModelInfo, error) { @@ -1826,19 +1827,17 @@ func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegistere var totalCount int = 0 limit := request.MaxResults iter := a.List(ctx, request) - var err error - var next RegisteredModelInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -2009,7 +2008,7 @@ func (a *SchemasAPI) GetByFullName(ctx context.Context, fullName string) (*Schem // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *listing.Iterator[ListSchemasRequest, *ListSchemasResponse, SchemaInfo] { +func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) (it listing.Iterator[SchemaInfo]) { getNextPage := func(ctx context.Context, req ListSchemasRequest) (*ListSchemasResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2019,25 +2018,25 @@ func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *list return resp.Schemas } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *SchemasAPI) ListAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) { var results []SchemaInfo iter := a.List(ctx, request) - var err error - var next SchemaInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -2198,7 +2197,7 @@ func (a *StorageCredentialsAPI) GetByName(ctx context.Context, name string) (*St // of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListStorageCredentialsResponse, StorageCredentialInfo] { +func (a *StorageCredentialsAPI) List(ctx context.Context) (it listing.Iterator[StorageCredentialInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListStorageCredentialsResponse, error) { @@ -2209,25 +2208,25 @@ func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.Iterator[stru return resp.StorageCredentials } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *StorageCredentialsAPI) ListAll(ctx context.Context) ([]StorageCredentialInfo, error) { var results []StorageCredentialInfo iter := a.List(ctx) - var err error - var next StorageCredentialInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -2343,7 +2342,7 @@ func (a *SystemSchemasAPI) Enable(ctx context.Context, request EnableRequest) er // account admin or a metastore admin. // // This method is generated by Databricks SDK Code Generator. -func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRequest) *listing.Iterator[ListSystemSchemasRequest, *ListSystemSchemasResponse, SystemSchemaInfo] { +func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRequest) (it listing.Iterator[SystemSchemaInfo]) { getNextPage := func(ctx context.Context, req ListSystemSchemasRequest) (*ListSystemSchemasResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2353,25 +2352,25 @@ func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRe return resp.Schemas } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *SystemSchemasAPI) ListAll(ctx context.Context, request ListSystemSchemasRequest) ([]SystemSchemaInfo, error) { var results []SystemSchemaInfo iter := a.List(ctx, request) - var err error - var next SystemSchemaInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -2566,7 +2565,7 @@ func (a *TablesAPI) GetByFullName(ctx context.Context, fullName string) (*TableI // guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listing.Iterator[ListTablesRequest, *ListTablesResponse, TableInfo] { +func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) (it listing.Iterator[TableInfo]) { getNextPage := func(ctx context.Context, req ListTablesRequest) (*ListTablesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2582,11 +2581,13 @@ func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listin request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { @@ -2594,19 +2595,17 @@ func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]T var totalCount int = 0 limit := request.MaxResults iter := a.List(ctx, request) - var err error - var next TableInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -2678,7 +2677,7 @@ func (a *TablesAPI) GetByName(ctx context.Context, name string) (*TableInfo, err // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequest) *listing.Iterator[ListSummariesRequest, *ListTableSummariesResponse, TableSummary] { +func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequest) (it listing.Iterator[TableSummary]) { getNextPage := func(ctx context.Context, req ListSummariesRequest) (*ListTableSummariesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2694,11 +2693,13 @@ func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequ request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesRequest) ([]TableSummary, error) { @@ -2706,19 +2707,17 @@ func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesR var totalCount int = 0 limit := request.MaxResults iter := a.ListSummaries(ctx, request) - var err error - var next TableSummary - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -2832,7 +2831,7 @@ func (a *VolumesAPI) DeleteByFullNameArg(ctx context.Context, fullNameArg string // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *listing.Iterator[ListVolumesRequest, *ListVolumesResponseContent, VolumeInfo] { +func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) (it listing.Iterator[VolumeInfo]) { getNextPage := func(ctx context.Context, req ListVolumesRequest) (*ListVolumesResponseContent, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2842,25 +2841,25 @@ func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *list return resp.Volumes } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *VolumesAPI) ListAll(ctx context.Context, request ListVolumesRequest) ([]VolumeInfo, error) { var results []VolumeInfo iter := a.List(ctx, request) - var err error - var next VolumeInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/compute/api.go b/service/compute/api.go index c96f1ae68..1fabf4a10 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -5,7 +5,6 @@ package compute import ( "context" - "errors" "fmt" "time" @@ -155,7 +154,7 @@ func (a *ClusterPoliciesAPI) GetPermissionsByClusterPolicyId(ctx context.Context // Returns a list of policies accessible by the requesting user. // // This method is generated by Databricks SDK Code Generator. -func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPoliciesRequest) *listing.Iterator[ListClusterPoliciesRequest, *ListPoliciesResponse, Policy] { +func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPoliciesRequest) (it listing.Iterator[Policy]) { getNextPage := func(ctx context.Context, req ListClusterPoliciesRequest) (*ListPoliciesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -165,25 +164,25 @@ func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPolici return resp.Policies } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request ListClusterPoliciesRequest) ([]Policy, error) { var results []Policy iter := a.List(ctx, request) - var err error - var next Policy - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -609,7 +608,7 @@ func (a *ClustersAPI) EditAndWait(ctx context.Context, editCluster EditCluster, // nparameters necessary to request the next page of events. // // This method is generated by Databricks SDK Code Generator. -func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.Iterator[GetEvents, *GetEventsResponse, ClusterEvent] { +func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) (it listing.Iterator[ClusterEvent]) { getNextPage := func(ctx context.Context, req GetEvents) (*GetEventsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -626,11 +625,13 @@ func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.It return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) { @@ -638,19 +639,17 @@ func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]Clust var totalCount int64 = 0 limit := request.Limit iter := a.Events(ctx, request) - var err error - var next ClusterEvent - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -719,7 +718,7 @@ func (a *ClustersAPI) GetPermissionsByClusterId(ctx context.Context, clusterId s // terminated job clusters. // // This method is generated by Databricks SDK Code Generator. -func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *listing.Iterator[ListClustersRequest, *ListClustersResponse, ClusterDetails] { +func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) (it listing.Iterator[ClusterDetails]) { getNextPage := func(ctx context.Context, req ListClustersRequest) (*ListClustersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -729,25 +728,25 @@ func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *li return resp.Clusters } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) ([]ClusterDetails, error) { var results []ClusterDetails iter := a.List(ctx, request) - var err error - var next ClusterDetails - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1557,7 +1556,7 @@ func (a *GlobalInitScriptsAPI) GetByScriptId(ctx context.Context, scriptId strin // script](#operation/get-script) operation. // // This method is generated by Databricks SDK Code Generator. -func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListGlobalInitScriptsResponse, GlobalInitScriptDetails] { +func (a *GlobalInitScriptsAPI) List(ctx context.Context) (it listing.Iterator[GlobalInitScriptDetails]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListGlobalInitScriptsResponse, error) { @@ -1568,25 +1567,25 @@ func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.Iterator[struc return resp.Scripts } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *GlobalInitScriptsAPI) ListAll(ctx context.Context) ([]GlobalInitScriptDetails, error) { var results []GlobalInitScriptDetails iter := a.List(ctx) - var err error - var next GlobalInitScriptDetails - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1782,7 +1781,7 @@ func (a *InstancePoolsAPI) GetPermissionsByInstancePoolId(ctx context.Context, i // Gets a list of instance pools with their statistics. // // This method is generated by Databricks SDK Code Generator. -func (a *InstancePoolsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListInstancePools, InstancePoolAndStats] { +func (a *InstancePoolsAPI) List(ctx context.Context) (it listing.Iterator[InstancePoolAndStats]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListInstancePools, error) { @@ -1793,25 +1792,25 @@ func (a *InstancePoolsAPI) List(ctx context.Context) *listing.Iterator[struct{}, return resp.InstancePools } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, error) { var results []InstancePoolAndStats iter := a.List(ctx) - var err error - var next InstancePoolAndStats - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1952,7 +1951,7 @@ func (a *InstanceProfilesAPI) Edit(ctx context.Context, request InstanceProfile) // This API is available to all users. // // This method is generated by Databricks SDK Code Generator. -func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListInstanceProfilesResponse, InstanceProfile] { +func (a *InstanceProfilesAPI) List(ctx context.Context) (it listing.Iterator[InstanceProfile]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListInstanceProfilesResponse, error) { @@ -1963,25 +1962,25 @@ func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.Iterator[struct return resp.InstanceProfiles } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *InstanceProfilesAPI) ListAll(ctx context.Context) ([]InstanceProfile, error) { var results []InstanceProfile iter := a.List(ctx) - var err error - var next InstanceProfile - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -2082,7 +2081,7 @@ func (a *LibrariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterL // guarantee. // // This method is generated by Databricks SDK Code Generator. -func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) *listing.Iterator[ClusterStatusRequest, *ClusterLibraryStatuses, LibraryFullStatus] { +func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) (it listing.Iterator[LibraryFullStatus]) { getNextPage := func(ctx context.Context, req ClusterStatusRequest) (*ClusterLibraryStatuses, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2092,25 +2091,25 @@ func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusR return resp.LibraryStatuses } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *LibrariesAPI) ClusterStatusAll(ctx context.Context, request ClusterStatusRequest) ([]LibraryFullStatus, error) { var results []LibraryFullStatus iter := a.ClusterStatus(ctx, request) - var err error - var next LibraryFullStatus - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -2214,7 +2213,7 @@ func (a *PolicyFamiliesAPI) GetByPolicyFamilyId(ctx context.Context, policyFamil // Retrieve a list of policy families. This API is paginated. // // This method is generated by Databricks SDK Code Generator. -func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamiliesRequest) *listing.Iterator[ListPolicyFamiliesRequest, *ListPolicyFamiliesResponse, PolicyFamily] { +func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamiliesRequest) (it listing.Iterator[PolicyFamily]) { getNextPage := func(ctx context.Context, req ListPolicyFamiliesRequest) (*ListPolicyFamiliesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2230,11 +2229,13 @@ func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamilies request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamiliesRequest) ([]PolicyFamily, error) { @@ -2242,18 +2243,16 @@ func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamil var totalCount int64 = 0 limit := request.MaxResults iter := a.List(ctx, request) - var err error - var next PolicyFamily - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/files/api.go b/service/files/api.go index caad67a3b..fb5ea491f 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -5,7 +5,6 @@ package files import ( "context" - "errors" "github.com/databricks/databricks-sdk-go/client" "github.com/databricks/databricks-sdk-go/listing" @@ -143,7 +142,7 @@ func (a *DbfsAPI) GetStatusByPath(ctx context.Context, path string) (*FileInfo, // which provides the same functionality without timing out. // // This method is generated by Databricks SDK Code Generator. -func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.Iterator[ListDbfsRequest, *ListStatusResponse, FileInfo] { +func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) (it listing.Iterator[FileInfo]) { getNextPage := func(ctx context.Context, req ListDbfsRequest) (*ListStatusResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -153,25 +152,25 @@ func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.It return resp.Files } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *DbfsAPI) ListAll(ctx context.Context, request ListDbfsRequest) ([]FileInfo, error) { var results []FileInfo iter := a.List(ctx, request) - var err error - var next FileInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/iam/api.go b/service/iam/api.go index 077fb8bc8..e287e8465 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -5,7 +5,6 @@ package iam import ( "context" - "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -204,7 +203,7 @@ func (a *AccountGroupsAPI) GetById(ctx context.Context, id string) (*Group, erro // Gets all details of the groups associated with the Databricks account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRequest) *listing.Iterator[ListAccountGroupsRequest, *ListGroupsResponse, Group] { +func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRequest) (it listing.Iterator[Group]) { getNextPage := func(ctx context.Context, req ListAccountGroupsRequest) (*ListGroupsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -214,25 +213,25 @@ func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRe return resp.Resources } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *AccountGroupsAPI) ListAll(ctx context.Context, request ListAccountGroupsRequest) ([]Group, error) { var results []Group iter := a.List(ctx, request) - var err error - var next Group - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -381,7 +380,7 @@ func (a *AccountServicePrincipalsAPI) GetById(ctx context.Context, id string) (* // Gets the set of service principals associated with a Databricks account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAccountServicePrincipalsRequest) *listing.Iterator[ListAccountServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { +func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAccountServicePrincipalsRequest) (it listing.Iterator[ServicePrincipal]) { getNextPage := func(ctx context.Context, req ListAccountServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -391,25 +390,25 @@ func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAcco return resp.Resources } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *AccountServicePrincipalsAPI) ListAll(ctx context.Context, request ListAccountServicePrincipalsRequest) ([]ServicePrincipal, error) { var results []ServicePrincipal iter := a.List(ctx, request) - var err error - var next ServicePrincipal - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -567,7 +566,7 @@ func (a *AccountUsersAPI) GetById(ctx context.Context, id string) (*User, error) // Gets details for all the users associated with a Databricks account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequest) *listing.Iterator[ListAccountUsersRequest, *ListUsersResponse, User] { +func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequest) (it listing.Iterator[User]) { getNextPage := func(ctx context.Context, req ListAccountUsersRequest) (*ListUsersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -577,25 +576,25 @@ func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequ return resp.Resources } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *AccountUsersAPI) ListAll(ctx context.Context, request ListAccountUsersRequest) ([]User, error) { var results []User iter := a.List(ctx, request) - var err error - var next User - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -780,7 +779,7 @@ func (a *GroupsAPI) GetById(ctx context.Context, id string) (*Group, error) { // Gets all details of the groups associated with the Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listing.Iterator[ListGroupsRequest, *ListGroupsResponse, Group] { +func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) (it listing.Iterator[Group]) { getNextPage := func(ctx context.Context, req ListGroupsRequest) (*ListGroupsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -790,25 +789,25 @@ func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listin return resp.Resources } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *GroupsAPI) ListAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { var results []Group iter := a.List(ctx, request) - var err error - var next Group - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1082,7 +1081,7 @@ func (a *ServicePrincipalsAPI) GetById(ctx context.Context, id string) (*Service // Gets the set of service principals associated with a Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrincipalsRequest) *listing.Iterator[ListServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { +func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrincipalsRequest) (it listing.Iterator[ServicePrincipal]) { getNextPage := func(ctx context.Context, req ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1092,25 +1091,25 @@ func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrin return resp.Resources } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ServicePrincipalsAPI) ListAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { var results []ServicePrincipal iter := a.List(ctx, request) - var err error - var next ServicePrincipal - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1283,7 +1282,7 @@ func (a *UsersAPI) GetPermissions(ctx context.Context) (*PasswordPermissions, er // Gets details for all the users associated with a Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing.Iterator[ListUsersRequest, *ListUsersResponse, User] { +func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) (it listing.Iterator[User]) { getNextPage := func(ctx context.Context, req ListUsersRequest) (*ListUsersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1293,25 +1292,25 @@ func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing. return resp.Resources } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *UsersAPI) ListAll(ctx context.Context, request ListUsersRequest) ([]User, error) { var results []User iter := a.List(ctx, request) - var err error - var next User - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1470,7 +1469,7 @@ func (a *WorkspaceAssignmentAPI) GetByWorkspaceId(ctx context.Context, workspace // Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspaceAssignmentRequest) *listing.Iterator[ListWorkspaceAssignmentRequest, *PermissionAssignments, PermissionAssignment] { +func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspaceAssignmentRequest) (it listing.Iterator[PermissionAssignment]) { getNextPage := func(ctx context.Context, req ListWorkspaceAssignmentRequest) (*PermissionAssignments, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1480,25 +1479,25 @@ func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspace return resp.PermissionAssignments } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorkspaceAssignmentRequest) ([]PermissionAssignment, error) { var results []PermissionAssignment iter := a.List(ctx, request) - var err error - var next PermissionAssignment - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/iam/model.go b/service/iam/model.go index d574aee29..ec5914020 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -1024,7 +1024,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Roles []ComplexValue `json:"roles,omitempty"` diff --git a/service/jobs/api.go b/service/jobs/api.go index 938f0ed0c..a64e561a5 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -5,7 +5,6 @@ package jobs import ( "context" - "errors" "fmt" "time" @@ -329,7 +328,7 @@ func (a *JobsAPI) GetRunOutputByRunId(ctx context.Context, runId int64) (*RunOut // Retrieves a list of jobs. // // This method is generated by Databricks SDK Code Generator. -func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.Iterator[ListJobsRequest, *ListJobsResponse, BaseJob] { +func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) (it listing.Iterator[BaseJob]) { getNextPage := func(ctx context.Context, req ListJobsRequest) (*ListJobsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -345,11 +344,13 @@ func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.It request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJob, error) { @@ -357,19 +358,17 @@ func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJ var totalCount int = 0 limit := request.Limit iter := a.List(ctx, request) - var err error - var next BaseJob - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -431,7 +430,7 @@ func (a *JobsAPI) GetBySettingsName(ctx context.Context, name string) (*BaseJob, // List runs in descending order by start time. // // This method is generated by Databricks SDK Code Generator. -func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listing.Iterator[ListRunsRequest, *ListRunsResponse, BaseRun] { +func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) (it listing.Iterator[BaseRun]) { getNextPage := func(ctx context.Context, req ListRunsRequest) (*ListRunsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -447,11 +446,13 @@ func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listin request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]BaseRun, error) { @@ -459,19 +460,17 @@ func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]B var totalCount int = 0 limit := request.Limit iter := a.ListRuns(ctx, request) - var err error - var next BaseRun - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/ml/api.go b/service/ml/api.go index e3e71dd5e..4a34b84f7 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -5,7 +5,6 @@ package ml import ( "context" - "errors" "github.com/databricks/databricks-sdk-go/client" "github.com/databricks/databricks-sdk-go/listing" @@ -128,7 +127,7 @@ func (a *ExperimentsAPI) GetExperiment(ctx context.Context, request GetExperimen // Gets a list of all values for the specified metric for a given run. // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) *listing.Iterator[GetHistoryRequest, *GetMetricHistoryResponse, Metric] { +func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) (it listing.Iterator[Metric]) { getNextPage := func(ctx context.Context, req GetHistoryRequest) (*GetMetricHistoryResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -144,11 +143,13 @@ func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryReque request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRequest) ([]Metric, error) { @@ -156,19 +157,17 @@ func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRe var totalCount int = 0 limit := request.MaxResults iter := a.GetHistory(ctx, request) - var err error - var next Metric - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -224,7 +223,7 @@ func (a *ExperimentsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Ge // specified, the response contains only artifacts with the specified prefix.", // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifactsRequest) *listing.Iterator[ListArtifactsRequest, *ListArtifactsResponse, FileInfo] { +func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifactsRequest) (it listing.Iterator[FileInfo]) { getNextPage := func(ctx context.Context, req ListArtifactsRequest) (*ListArtifactsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -240,25 +239,25 @@ func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifact request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) { var results []FileInfo iter := a.ListArtifacts(ctx, request) - var err error - var next FileInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -267,7 +266,7 @@ func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtif // Gets a list of all experiments. // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperimentsRequest) *listing.Iterator[ListExperimentsRequest, *ListExperimentsResponse, Experiment] { +func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperimentsRequest) (it listing.Iterator[Experiment]) { getNextPage := func(ctx context.Context, req ListExperimentsRequest) (*ListExperimentsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -283,11 +282,13 @@ func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperi request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) { @@ -295,19 +296,17 @@ func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExp var totalCount int = 0 limit := request.MaxResults iter := a.ListExperiments(ctx, request) - var err error - var next Experiment - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -421,7 +420,7 @@ func (a *ExperimentsAPI) RestoreRuns(ctx context.Context, request RestoreRuns) ( // Searches for experiments that satisfy specified search criteria. // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchExperiments) *listing.Iterator[SearchExperiments, *SearchExperimentsResponse, Experiment] { +func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchExperiments) (it listing.Iterator[Experiment]) { getNextPage := func(ctx context.Context, req SearchExperiments) (*SearchExperimentsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -437,25 +436,25 @@ func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchEx request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) { var results []Experiment iter := a.SearchExperiments(ctx, request) - var err error - var next Experiment - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -466,7 +465,7 @@ func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request Searc // Search expressions can use `mlflowMetric` and `mlflowParam` keys.", // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *listing.Iterator[SearchRuns, *SearchRunsResponse, Run] { +func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) (it listing.Iterator[Run]) { getNextPage := func(ctx context.Context, req SearchRuns) (*SearchRunsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -482,25 +481,25 @@ func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *li request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) ([]Run, error) { var results []Run iter := a.SearchRuns(ctx, request) - var err error - var next Run - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -683,7 +682,7 @@ func (a *ModelRegistryAPI) DeleteWebhook(ctx context.Context, request DeleteWebh // Gets the latest version of a registered model. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) *listing.Iterator[GetLatestVersionsRequest, *GetLatestVersionsResponse, ModelVersion] { +func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) (it listing.Iterator[ModelVersion]) { getNextPage := func(ctx context.Context, req GetLatestVersionsRequest) (*GetLatestVersionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -693,25 +692,25 @@ func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLat return resp.ModelVersions } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ModelRegistryAPI) GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) { var results []ModelVersion iter := a.GetLatestVersions(ctx, request) - var err error - var next ModelVersion - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -780,7 +779,7 @@ func (a *ModelRegistryAPI) GetPermissionsByRegisteredModelId(ctx context.Context // __max_results__. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsRequest) *listing.Iterator[ListModelsRequest, *ListModelsResponse, Model] { +func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsRequest) (it listing.Iterator[Model]) { getNextPage := func(ctx context.Context, req ListModelsRequest) (*ListModelsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -796,11 +795,13 @@ func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsReq request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModelsRequest) ([]Model, error) { @@ -808,19 +809,17 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels var totalCount int = 0 limit := request.MaxResults iter := a.ListModels(ctx, request) - var err error - var next Model - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -829,7 +828,7 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels // Gets a list of all open stage transition requests for the model version. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request ListTransitionRequestsRequest) *listing.Iterator[ListTransitionRequestsRequest, *ListTransitionRequestsResponse, Activity] { +func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request ListTransitionRequestsRequest) (it listing.Iterator[Activity]) { getNextPage := func(ctx context.Context, req ListTransitionRequestsRequest) (*ListTransitionRequestsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -839,25 +838,25 @@ func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request L return resp.Requests } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, request ListTransitionRequestsRequest) ([]Activity, error) { var results []Activity iter := a.ListTransitionRequests(ctx, request) - var err error - var next Activity - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -868,7 +867,7 @@ func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, reques // Lists all registry webhooks. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhooksRequest) *listing.Iterator[ListWebhooksRequest, *ListRegistryWebhooks, RegistryWebhook] { +func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhooksRequest) (it listing.Iterator[RegistryWebhook]) { getNextPage := func(ctx context.Context, req ListWebhooksRequest) (*ListRegistryWebhooks, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -884,25 +883,25 @@ func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhook request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebhooksRequest) ([]RegistryWebhook, error) { var results []RegistryWebhook iter := a.ListWebhooks(ctx, request) - var err error - var next RegistryWebhook - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -925,7 +924,7 @@ func (a *ModelRegistryAPI) RenameModel(ctx context.Context, request RenameModelR // Searches for specific model versions based on the supplied __filter__. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request SearchModelVersionsRequest) *listing.Iterator[SearchModelVersionsRequest, *SearchModelVersionsResponse, ModelVersion] { +func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request SearchModelVersionsRequest) (it listing.Iterator[ModelVersion]) { getNextPage := func(ctx context.Context, req SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -941,11 +940,13 @@ func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request Sear request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) { @@ -953,19 +954,17 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S var totalCount int = 0 limit := request.MaxResults iter := a.SearchModelVersions(ctx, request) - var err error - var next ModelVersion - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -974,7 +973,7 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S // Search for registered models based on the specified __filter__. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModelsRequest) *listing.Iterator[SearchModelsRequest, *SearchModelsResponse, Model] { +func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModelsRequest) (it listing.Iterator[Model]) { getNextPage := func(ctx context.Context, req SearchModelsRequest) (*SearchModelsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -990,11 +989,13 @@ func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModel request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchModelsRequest) ([]Model, error) { @@ -1002,19 +1003,17 @@ func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchMo var totalCount int = 0 limit := request.MaxResults iter := a.SearchModels(ctx, request) - var err error - var next Model - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index 7199cd404..1c9daa483 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -58,24 +58,24 @@ func ExampleModelRegistryAPI_CreateComment_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_models() { +func ExampleModelRegistryAPI_CreateModel_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", model) } -func ExampleModelRegistryAPI_CreateModel_modelVersions() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -92,24 +92,24 @@ func ExampleModelRegistryAPI_CreateModel_modelVersions() { } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_models() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", model) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -124,18 +124,18 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { } logger.Infof(ctx, "found %v", model) - created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", mv) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -150,14 +150,14 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { } logger.Infof(ctx, "found %v", model) - mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", mv) + logger.Infof(ctx, "found %v", created) } diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 230887fa5..3347d17fb 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -5,7 +5,6 @@ package oauth2 import ( "context" - "errors" "github.com/databricks/databricks-sdk-go/client" "github.com/databricks/databricks-sdk-go/listing" @@ -91,7 +90,7 @@ func (a *CustomAppIntegrationAPI) GetByIntegrationId(ctx context.Context, integr // account // // This method is generated by Databricks SDK Code Generator. -func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetCustomAppIntegrationsOutput, GetCustomAppIntegrationOutput] { +func (a *CustomAppIntegrationAPI) List(ctx context.Context) (it listing.Iterator[GetCustomAppIntegrationOutput]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetCustomAppIntegrationsOutput, error) { @@ -102,25 +101,25 @@ func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[st return resp.Apps } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIntegrationOutput, error) { var results []GetCustomAppIntegrationOutput iter := a.List(ctx) - var err error - var next GetCustomAppIntegrationOutput - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -223,7 +222,7 @@ func (a *OAuthPublishedAppsAPI) Impl() OAuthPublishedAppsService { // Get all the available published OAuth apps in Databricks. // // This method is generated by Databricks SDK Code Generator. -func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPublishedAppsRequest) *listing.Iterator[ListOAuthPublishedAppsRequest, *GetPublishedAppsOutput, PublishedAppOutput] { +func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPublishedAppsRequest) (it listing.Iterator[PublishedAppOutput]) { getNextPage := func(ctx context.Context, req ListOAuthPublishedAppsRequest) (*GetPublishedAppsOutput, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -239,11 +238,13 @@ func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPubli request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPublishedAppsRequest) ([]PublishedAppOutput, error) { @@ -251,19 +252,17 @@ func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPu var totalCount int64 = 0 limit := request.PageSize iter := a.List(ctx, request) - var err error - var next PublishedAppOutput - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -346,7 +345,7 @@ func (a *PublishedAppIntegrationAPI) GetByIntegrationId(ctx context.Context, int // account // // This method is generated by Databricks SDK Code Generator. -func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetPublishedAppIntegrationsOutput, GetPublishedAppIntegrationOutput] { +func (a *PublishedAppIntegrationAPI) List(ctx context.Context) (it listing.Iterator[GetPublishedAppIntegrationOutput]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetPublishedAppIntegrationsOutput, error) { @@ -357,25 +356,25 @@ func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.Iterator return resp.Apps } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishedAppIntegrationOutput, error) { var results []GetPublishedAppIntegrationOutput iter := a.List(ctx) - var err error - var next GetPublishedAppIntegrationOutput - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -457,7 +456,7 @@ func (a *ServicePrincipalSecretsAPI) DeleteByServicePrincipalIdAndSecretId(ctx c // the secret values. // // This method is generated by Databricks SDK Code Generator. -func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServicePrincipalSecretsRequest) *listing.Iterator[ListServicePrincipalSecretsRequest, *ListServicePrincipalSecretsResponse, SecretInfo] { +func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServicePrincipalSecretsRequest) (it listing.Iterator[SecretInfo]) { getNextPage := func(ctx context.Context, req ListServicePrincipalSecretsRequest) (*ListServicePrincipalSecretsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -467,25 +466,25 @@ func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServi return resp.Secrets } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ServicePrincipalSecretsAPI) ListAll(ctx context.Context, request ListServicePrincipalSecretsRequest) ([]SecretInfo, error) { var results []SecretInfo iter := a.List(ctx, request) - var err error - var next SecretInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 25302b647..7477482f5 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -5,7 +5,6 @@ package pipelines import ( "context" - "errors" "fmt" "time" @@ -255,7 +254,7 @@ func (a *PipelinesAPI) GetUpdateByPipelineIdAndUpdateId(ctx context.Context, pip // Retrieves events for a pipeline. // // This method is generated by Databricks SDK Code Generator. -func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipelineEventsRequest) *listing.Iterator[ListPipelineEventsRequest, *ListPipelineEventsResponse, PipelineEvent] { +func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipelineEventsRequest) (it listing.Iterator[PipelineEvent]) { getNextPage := func(ctx context.Context, req ListPipelineEventsRequest) (*ListPipelineEventsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -271,11 +270,13 @@ func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipel request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPipelineEventsRequest) ([]PipelineEvent, error) { @@ -283,19 +284,17 @@ func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPi var totalCount int = 0 limit := request.MaxResults iter := a.ListPipelineEvents(ctx, request) - var err error - var next PipelineEvent - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -313,7 +312,7 @@ func (a *PipelinesAPI) ListPipelineEventsByPipelineId(ctx context.Context, pipel // Lists pipelines defined in the Delta Live Tables system. // // This method is generated by Databricks SDK Code Generator. -func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesRequest) *listing.Iterator[ListPipelinesRequest, *ListPipelinesResponse, PipelineStateInfo] { +func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesRequest) (it listing.Iterator[PipelineStateInfo]) { getNextPage := func(ctx context.Context, req ListPipelinesRequest) (*ListPipelinesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -329,11 +328,13 @@ func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesR request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelinesRequest) ([]PipelineStateInfo, error) { @@ -341,19 +342,17 @@ func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelin var totalCount int = 0 limit := request.MaxResults iter := a.ListPipelines(ctx, request) - var err error - var next PipelineStateInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/serving/api.go b/service/serving/api.go index 0acc54693..ac587077f 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -5,7 +5,6 @@ package serving import ( "context" - "errors" "fmt" "time" @@ -254,7 +253,7 @@ func (a *ServingEndpointsAPI) GetPermissionsByServingEndpointId(ctx context.Cont // Retrieve all serving endpoints. // // This method is generated by Databricks SDK Code Generator. -func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListEndpointsResponse, ServingEndpoint] { +func (a *ServingEndpointsAPI) List(ctx context.Context) (it listing.Iterator[ServingEndpoint]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListEndpointsResponse, error) { @@ -265,25 +264,25 @@ func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.Iterator[struct return resp.Endpoints } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ServingEndpointsAPI) ListAll(ctx context.Context) ([]ServingEndpoint, error) { var results []ServingEndpoint iter := a.List(ctx) - var err error - var next ServingEndpoint - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/settings/api.go b/service/settings/api.go index 197b968c0..86a305302 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -5,7 +5,6 @@ package settings import ( "context" - "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -118,7 +117,7 @@ func (a *AccountIpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAcc // Gets all IP access lists for the specified account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetIpAccessListsResponse, IpAccessListInfo] { +func (a *AccountIpAccessListsAPI) List(ctx context.Context) (it listing.Iterator[IpAccessListInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetIpAccessListsResponse, error) { @@ -129,25 +128,25 @@ func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.Iterator[st return resp.IpAccessLists } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *AccountIpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { var results []IpAccessListInfo iter := a.List(ctx) - var err error - var next IpAccessListInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -439,7 +438,7 @@ func (a *IpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAccessList // Gets all IP access lists for the specified workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *IpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListIpAccessListResponse, IpAccessListInfo] { +func (a *IpAccessListsAPI) List(ctx context.Context) (it listing.Iterator[IpAccessListInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListIpAccessListResponse, error) { @@ -450,25 +449,25 @@ func (a *IpAccessListsAPI) List(ctx context.Context) *listing.Iterator[struct{}, return resp.IpAccessLists } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *IpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { var results []IpAccessListInfo iter := a.List(ctx) - var err error - var next IpAccessListInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -706,7 +705,7 @@ func (a *TokenManagementAPI) GetPermissions(ctx context.Context) (*TokenPermissi // Lists all tokens associated with the specified workspace or user. // // This method is generated by Databricks SDK Code Generator. -func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManagementRequest) *listing.Iterator[ListTokenManagementRequest, *ListTokensResponse, TokenInfo] { +func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManagementRequest) (it listing.Iterator[TokenInfo]) { getNextPage := func(ctx context.Context, req ListTokenManagementRequest) (*ListTokensResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -716,25 +715,25 @@ func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManageme return resp.TokenInfos } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *TokenManagementAPI) ListAll(ctx context.Context, request ListTokenManagementRequest) ([]TokenInfo, error) { var results []TokenInfo iter := a.List(ctx, request) - var err error - var next TokenInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -872,7 +871,7 @@ func (a *TokensAPI) DeleteByTokenId(ctx context.Context, tokenId string) error { // Lists all the valid tokens for a user-workspace pair. // // This method is generated by Databricks SDK Code Generator. -func (a *TokensAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListTokensResponse, TokenInfo] { +func (a *TokensAPI) List(ctx context.Context) (it listing.Iterator[TokenInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListTokensResponse, error) { @@ -883,25 +882,25 @@ func (a *TokensAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListT return resp.TokenInfos } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *TokensAPI) ListAll(ctx context.Context) ([]TokenInfo, error) { var results []TokenInfo iter := a.List(ctx) - var err error - var next TokenInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/sharing/api.go b/service/sharing/api.go index 6d930cf60..f2c1a0bb2 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -5,7 +5,6 @@ package sharing import ( "context" - "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -97,7 +96,7 @@ func (a *CleanRoomsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Clea // a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) *listing.Iterator[ListCleanRoomsRequest, *ListCleanRoomsResponse, CleanRoomInfo] { +func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) (it listing.Iterator[CleanRoomInfo]) { getNextPage := func(ctx context.Context, req ListCleanRoomsRequest) (*ListCleanRoomsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -113,11 +112,13 @@ func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsRequest) ([]CleanRoomInfo, error) { @@ -125,19 +126,17 @@ func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsReque var totalCount int = 0 limit := request.MaxResults iter := a.List(ctx, request) - var err error - var next CleanRoomInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -245,7 +244,7 @@ func (a *ProvidersAPI) GetByName(ctx context.Context, name string) (*ProviderInf // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) *listing.Iterator[ListProvidersRequest, *ListProvidersResponse, ProviderInfo] { +func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) (it listing.Iterator[ProviderInfo]) { getNextPage := func(ctx context.Context, req ListProvidersRequest) (*ListProvidersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -255,25 +254,25 @@ func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) * return resp.Providers } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ProvidersAPI) ListAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) { var results []ProviderInfo iter := a.List(ctx, request) - var err error - var next ProviderInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -309,7 +308,7 @@ func (a *ProvidersAPI) ProviderInfoNameToMetastoreIdMap(ctx context.Context, req // * the caller is a metastore admin, or * the caller is the owner. // // This method is generated by Databricks SDK Code Generator. -func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest) *listing.Iterator[ListSharesRequest, *ListProviderSharesResponse, ProviderShare] { +func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest) (it listing.Iterator[ProviderShare]) { getNextPage := func(ctx context.Context, req ListSharesRequest) (*ListProviderSharesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -319,25 +318,25 @@ func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest return resp.Shares } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *ProvidersAPI) ListSharesAll(ctx context.Context, request ListSharesRequest) ([]ProviderShare, error) { var results []ProviderShare iter := a.ListShares(ctx, request) - var err error - var next ProviderShare - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -530,7 +529,7 @@ func (a *RecipientsAPI) GetByName(ctx context.Context, name string) (*RecipientI // guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) *listing.Iterator[ListRecipientsRequest, *ListRecipientsResponse, RecipientInfo] { +func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) (it listing.Iterator[RecipientInfo]) { getNextPage := func(ctx context.Context, req ListRecipientsRequest) (*ListRecipientsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -540,25 +539,25 @@ func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) return resp.Recipients } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *RecipientsAPI) ListAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) { var results []RecipientInfo iter := a.List(ctx, request) - var err error - var next RecipientInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -706,7 +705,7 @@ func (a *SharesAPI) GetByName(ctx context.Context, name string) (*ShareInfo, err // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *SharesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListSharesResponse, ShareInfo] { +func (a *SharesAPI) List(ctx context.Context) (it listing.Iterator[ShareInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListSharesResponse, error) { @@ -717,25 +716,25 @@ func (a *SharesAPI) List(ctx context.Context) *listing.Iterator[struct{}, *ListS return resp.Shares } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *SharesAPI) ListAll(ctx context.Context) ([]ShareInfo, error) { var results []ShareInfo iter := a.List(ctx) - var err error - var next ShareInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/sql/api.go b/service/sql/api.go index fc345f7f1..369e44d0f 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -5,7 +5,6 @@ package sql import ( "context" - "errors" "fmt" "time" @@ -287,7 +286,7 @@ func (a *DashboardsAPI) GetByDashboardId(ctx context.Context, dashboardId string // Fetch a paginated list of dashboard objects. // // This method is generated by Databricks SDK Code Generator. -func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) *listing.Iterator[ListDashboardsRequest, *ListResponse, Dashboard] { +func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) (it listing.Iterator[Dashboard]) { request.Page = 1 // start iterating from the first page @@ -305,11 +304,17 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) request.Page = resp.Page + 1 return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + it = listing.NewDedupeIterator( + it, + func(item Dashboard) string { + return item.Id + }) + return it } func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { @@ -317,26 +322,17 @@ func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsReque var totalCount int = 0 limit := request.PageSize iter := a.List(ctx, request) - // deduplicate items that may have been added during iteration - seen := map[string]bool{} - var err error - var next Dashboard - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - id := next.Id - if seen[id] { - // item was added during iteration - continue + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err } - seen[id] = true results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -661,7 +657,7 @@ func (a *QueriesAPI) GetByQueryId(ctx context.Context, queryId string) (*Query, // term. // // This method is generated by Databricks SDK Code Generator. -func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *listing.Iterator[ListQueriesRequest, *QueryList, Query] { +func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) (it listing.Iterator[Query]) { request.Page = 1 // start iterating from the first page @@ -679,11 +675,17 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *list request.Page = resp.Page + 1 return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + it = listing.NewDedupeIterator( + it, + func(item Query) string { + return item.Id + }) + return it } func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { @@ -691,26 +693,17 @@ func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([ var totalCount int = 0 limit := request.PageSize iter := a.List(ctx, request) - // deduplicate items that may have been added during iteration - seen := map[string]bool{} - var err error - var next Query - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - id := next.Id - if seen[id] { - // item was added during iteration - continue + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err } - seen[id] = true results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -818,7 +811,7 @@ func (a *QueryHistoryAPI) Impl() QueryHistoryService { // You can filter by user ID, warehouse ID, status, and time range. // // This method is generated by Databricks SDK Code Generator. -func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequest) *listing.Iterator[ListQueryHistoryRequest, *ListQueriesResponse, QueryInfo] { +func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequest) (it listing.Iterator[QueryInfo]) { getNextPage := func(ctx context.Context, req ListQueryHistoryRequest) (*ListQueriesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -834,11 +827,13 @@ func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequ request.PageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) { @@ -846,19 +841,17 @@ func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryR var totalCount int = 0 limit := request.MaxResults iter := a.List(ctx, request) - var err error - var next QueryInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) totalCount++ if limit > 0 && totalCount >= limit { break } } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -1428,7 +1421,7 @@ func (a *WarehousesAPI) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWo // Lists all SQL warehouses that a user has manager permissions on. // // This method is generated by Databricks SDK Code Generator. -func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) *listing.Iterator[ListWarehousesRequest, *ListWarehousesResponse, EndpointInfo] { +func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) (it listing.Iterator[EndpointInfo]) { getNextPage := func(ctx context.Context, req ListWarehousesRequest) (*ListWarehousesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1438,25 +1431,25 @@ func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) return resp.Warehouses } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *WarehousesAPI) ListAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) { var results []EndpointInfo iter := a.List(ctx, request) - var err error - var next EndpointInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } diff --git a/service/workspace/api.go b/service/workspace/api.go index 540aca781..4d8314ed3 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -5,7 +5,6 @@ package workspace import ( "context" - "errors" "fmt" "github.com/databricks/databricks-sdk-go/client" @@ -93,7 +92,7 @@ func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId // supported. // // This method is generated by Databricks SDK Code Generator. -func (a *GitCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{}, *GetCredentialsResponse, CredentialInfo] { +func (a *GitCredentialsAPI) List(ctx context.Context) (it listing.Iterator[CredentialInfo]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetCredentialsResponse, error) { @@ -104,25 +103,25 @@ func (a *GitCredentialsAPI) List(ctx context.Context) *listing.Iterator[struct{} return resp.Credentials } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error) { var results []CredentialInfo iter := a.List(ctx) - var err error - var next CredentialInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -303,7 +302,7 @@ func (a *ReposAPI) GetPermissionsByRepoId(ctx context.Context, repoId string) (* // paginated with each page containing twenty repos. // // This method is generated by Databricks SDK Code Generator. -func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing.Iterator[ListReposRequest, *ListReposResponse, RepoInfo] { +func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) (it listing.Iterator[RepoInfo]) { getNextPage := func(ctx context.Context, req ListReposRequest) (*ListReposResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -319,25 +318,25 @@ func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing. request.NextPageToken = resp.NextPageToken return &request } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, getNextReq) + + return it } func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error) { var results []RepoInfo iter := a.List(ctx, request) - var err error - var next RepoInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -553,7 +552,7 @@ func (a *SecretsAPI) GetSecret(ctx context.Context, request GetSecretRequest) (* // call. // // This method is generated by Databricks SDK Code Generator. -func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *listing.Iterator[ListAclsRequest, *ListAclsResponse, AclItem] { +func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) (it listing.Iterator[AclItem]) { getNextPage := func(ctx context.Context, req ListAclsRequest) (*ListAclsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -563,25 +562,25 @@ func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *lis return resp.Items } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) { var results []AclItem iter := a.ListAcls(ctx, request) - var err error - var next AclItem - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -607,7 +606,7 @@ func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAc // API call. // // This method is generated by Databricks SDK Code Generator. -func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.Iterator[struct{}, *ListScopesResponse, SecretScope] { +func (a *SecretsAPI) ListScopes(ctx context.Context) (it listing.Iterator[SecretScope]) { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListScopesResponse, error) { @@ -618,25 +617,25 @@ func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.Iterator[struct{}, return resp.Scopes } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { var results []SecretScope iter := a.ListScopes(ctx) - var err error - var next SecretScope - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -652,7 +651,7 @@ func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { // call. // // This method is generated by Databricks SDK Code Generator. -func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) *listing.Iterator[ListSecretsRequest, *ListSecretsResponse, SecretMetadata] { +func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) (it listing.Iterator[SecretMetadata]) { getNextPage := func(ctx context.Context, req ListSecretsRequest) (*ListSecretsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -662,25 +661,25 @@ func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest return resp.Secrets } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) { var results []SecretMetadata iter := a.ListSecrets(ctx, request) - var err error - var next SecretMetadata - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } @@ -889,7 +888,7 @@ func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error { // `RESOURCE_DOES_NOT_EXIST`. // // This method is generated by Databricks SDK Code Generator. -func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) *listing.Iterator[ListWorkspaceRequest, *ListResponse, ObjectInfo] { +func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) (it listing.Iterator[ObjectInfo]) { getNextPage := func(ctx context.Context, req ListWorkspaceRequest) (*ListResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -899,25 +898,25 @@ func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) * return resp.Objects } - return listing.NewIterator( + it = listing.NewIterator( &request, getNextPage, getItems, nil) + + return it } func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error) { var results []ObjectInfo iter := a.List(ctx, request) - var err error - var next ObjectInfo - for next, err = iter.Next(ctx); err == nil; next, err = iter.Next(ctx) { - + for iter.HasNext(ctx) { + next, err := iter.Next(ctx) + if err != nil { + return nil, err + } results = append(results, next) } - if err != nil && !errors.Is(err, listing.ErrNoMoreItems) { - return nil, err - } return results, nil } From 58a4eebafc2d3ee4e12b5a36f2b3f316038044bf Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 15:50:53 +0200 Subject: [PATCH 11/24] remove extra changes --- .codegen/accounts.go.tmpl | 1 - .codegen/api.go.tmpl | 1 - .codegen/model.go.tmpl | 1 - .codegen/workspaces.go.tmpl | 1 - service/iam/model.go | 4 ++-- service/ml/model_registry_usage_test.go | 24 ++++++++++++------------ service/sql/model.go | 1 - 7 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.codegen/accounts.go.tmpl b/.codegen/accounts.go.tmpl index 2b3e1001f..e5fa3c9ba 100644 --- a/.codegen/accounts.go.tmpl +++ b/.codegen/accounts.go.tmpl @@ -3,7 +3,6 @@ package databricks import ( - "errors" "github.com/databricks/databricks-sdk-go/client" {{range .Packages}} "github.com/databricks/databricks-sdk-go/service/{{.Name}}" diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 54102f6f0..cb2db08a2 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -5,7 +5,6 @@ package {{.Name}} import ( "context" - "errors" "fmt" "time" "github.com/databricks/databricks-sdk-go/retries" diff --git a/.codegen/model.go.tmpl b/.codegen/model.go.tmpl index 59458b938..b4ba91cd0 100644 --- a/.codegen/model.go.tmpl +++ b/.codegen/model.go.tmpl @@ -5,7 +5,6 @@ package {{.Name}} import ( {{range .ImportedPackages}} "github.com/databricks/databricks-sdk-go/service/{{.}}"{{end}} - "fmt" "io" "github.com/databricks/databricks-sdk-go/marshal" ) diff --git a/.codegen/workspaces.go.tmpl b/.codegen/workspaces.go.tmpl index d964b4a8f..d7d261cdb 100644 --- a/.codegen/workspaces.go.tmpl +++ b/.codegen/workspaces.go.tmpl @@ -3,7 +3,6 @@ package databricks import ( - "errors" "github.com/databricks/databricks-sdk-go/client" {{range .Packages}} "github.com/databricks/databricks-sdk-go/service/{{.Name}}"{{end}} diff --git a/service/iam/model.go b/service/iam/model.go index ec5914020..f08919356 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,7 @@ type Group struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks group ID - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Members []ComplexValue `json:"members,omitempty"` // Container for the group identifier. Workspace local versus account. @@ -1024,7 +1024,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty" url:"-"` + Id string `json:"id,omitempty"` Roles []ComplexValue `json:"roles,omitempty"` diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index 1c9daa483..8675739f9 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -75,41 +75,41 @@ func ExampleModelRegistryAPI_CreateModel_modelVersions() { } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_models() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", model) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModel_models() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", model) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -124,18 +124,18 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { } logger.Infof(ctx, "found %v", model) - mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", mv) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -150,14 +150,14 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { } logger.Infof(ctx, "found %v", model) - created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", mv) } diff --git a/service/sql/model.go b/service/sql/model.go index d4db5f8a3..8e2fc3298 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -280,7 +280,6 @@ func (s ChannelInfo) MarshalJSON() ([]byte, error) { return marshal.Marshal(s) } -// Name of the channel type ChannelName string const ChannelNameChannelNameCurrent ChannelName = `CHANNEL_NAME_CURRENT` From 0de82e96511572d405f473c49efb38e8e74cbd72 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 16:02:24 +0200 Subject: [PATCH 12/24] add ToSlice for convenience --- .codegen/api.go.tmpl | 10 +- listing/listing.go | 12 +++ service/billing/api.go | 20 +--- service/catalog/api.go | 122 ++++-------------------- service/compute/api.go | 66 ++----------- service/files/api.go | 10 +- service/iam/api.go | 70 ++------------ service/iam/model.go | 2 +- service/jobs/api.go | 6 +- service/ml/api.go | 75 ++++----------- service/ml/model_registry_usage_test.go | 12 +-- service/oauth2/api.go | 33 +------ service/pipelines/api.go | 6 +- service/serving/api.go | 10 +- service/settings/api.go | 40 +------- service/sharing/api.go | 43 ++------- service/sql/api.go | 19 ++-- service/workspace/api.go | 60 ++---------- 18 files changed, 116 insertions(+), 500 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index cb2db08a2..9e0b69fd4 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -215,26 +215,26 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} } func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{ template "type" .Pagination.Entity }}, error) { - var results []{{ template "type" .Pagination.Entity }} + iter := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) {{ if .Pagination.Limit -}} + var results []{{ template "type" .Pagination.Entity }} var totalCount {{template "type" .Pagination.Limit.Entity}} = 0 limit := request.{{.Pagination.Limit.PascalName}} - {{ end -}} - iter := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { return nil, err } results = append(results, next) - {{ if .Pagination.Limit -}} totalCount++ if limit > 0 && totalCount >= limit { break } - {{- end -}} } return results, nil + {{ else -}} + return listing.ToSlice(ctx, iter) + {{- end }} } {{end}}{{if .NamedIdMap}} // {{.NamedIdMap.PascalName}} calls [{{.Service.Name}}API.{{.PascalName}}{{if not .NamedIdMap.Direct}}All{{end -}}] and creates a map of results with [{{.NamedIdMap.Entity.PascalName}}]{{ template "field-path" .NamedIdMap.NamePath }} as key and [{{.NamedIdMap.Entity.PascalName}}]{{ template "field-path" .NamedIdMap.IdPath}} as value. diff --git a/listing/listing.go b/listing/listing.go index b7d8c8873..18f2f3c25 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -10,6 +10,18 @@ type Iterator[T any] interface { Next(context.Context) (T, error) } +func ToSlice[T any](ctx context.Context, it Iterator[T]) ([]T, error) { + var items []T + for it.HasNext(ctx) { + item, err := it.Next(ctx) + if err != nil { + return nil, err + } + items = append(items, item) + } + return items, nil +} + // Use struct{} for Req to indicate one-shot iterator. type IteratorImpl[Req, Resp, T any] struct { // nextReq is the request to be used to fetch the next page. If nil, then diff --git a/service/billing/api.go b/service/billing/api.go index 3b8794bb8..18f1250e8 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -152,16 +152,8 @@ func (a *BudgetsAPI) List(ctx context.Context) (it listing.Iterator[BudgetWithSt } func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { - var results []BudgetWithStatus iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // BudgetWithStatusNameToBudgetIdMap calls [BudgetsAPI.ListAll] and creates a map of results with [BudgetWithStatus].Name as key and [BudgetWithStatus].BudgetId as value. @@ -387,16 +379,8 @@ func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryReques } func (a *LogDeliveryAPI) ListAll(ctx context.Context, request ListLogDeliveryRequest) ([]LogDeliveryConfiguration, error) { - var results []LogDeliveryConfiguration iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // LogDeliveryConfigurationConfigNameToConfigIdMap calls [LogDeliveryAPI.ListAll] and creates a map of results with [LogDeliveryConfiguration].ConfigName as key and [LogDeliveryConfiguration].ConfigId as value. diff --git a/service/catalog/api.go b/service/catalog/api.go index 3694b2910..1aca8e216 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -113,16 +113,8 @@ func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListA } func (a *AccountMetastoreAssignmentsAPI) ListAll(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) ([]int64, error) { - var results []int64 iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Get all workspaces assigned to a metastore. @@ -236,16 +228,8 @@ func (a *AccountMetastoresAPI) List(ctx context.Context) (it listing.Iterator[Me } func (a *AccountMetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { - var results []MetastoreInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Update a metastore. @@ -582,16 +566,8 @@ func (a *CatalogsAPI) List(ctx context.Context) (it listing.Iterator[CatalogInfo } func (a *CatalogsAPI) ListAll(ctx context.Context) ([]CatalogInfo, error) { - var results []CatalogInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Update a catalog. @@ -709,16 +685,8 @@ func (a *ConnectionsAPI) List(ctx context.Context) (it listing.Iterator[Connecti } func (a *ConnectionsAPI) ListAll(ctx context.Context) ([]ConnectionInfo, error) { - var results []ConnectionInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // ConnectionInfoNameToFullNameMap calls [ConnectionsAPI.ListAll] and creates a map of results with [ConnectionInfo].Name as key and [ConnectionInfo].FullName as value. @@ -897,16 +865,8 @@ func (a *ExternalLocationsAPI) List(ctx context.Context) (it listing.Iterator[Ex } func (a *ExternalLocationsAPI) ListAll(ctx context.Context) ([]ExternalLocationInfo, error) { - var results []ExternalLocationInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Update an external location. @@ -1048,16 +1008,8 @@ func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) ( } func (a *FunctionsAPI) ListAll(ctx context.Context, request ListFunctionsRequest) ([]FunctionInfo, error) { - var results []FunctionInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // FunctionInfoNameToFullNameMap calls [FunctionsAPI.ListAll] and creates a map of results with [FunctionInfo].Name as key and [FunctionInfo].FullName as value. @@ -1309,16 +1261,8 @@ func (a *MetastoresAPI) List(ctx context.Context) (it listing.Iterator[Metastore } func (a *MetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { - var results []MetastoreInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // MetastoreInfoNameToMetastoreIdMap calls [MetastoresAPI.ListAll] and creates a map of results with [MetastoreInfo].Name as key and [MetastoreInfo].MetastoreId as value. @@ -1575,10 +1519,10 @@ func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRe } func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersionsRequest) ([]ModelVersionInfo, error) { + iter := a.List(ctx, request) var results []ModelVersionInfo var totalCount int = 0 limit := request.MaxResults - iter := a.List(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -1591,6 +1535,7 @@ func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersion } } return results, nil + } // List Model Versions. @@ -1823,10 +1768,10 @@ func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredMo } func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegisteredModelsRequest) ([]RegisteredModelInfo, error) { + iter := a.List(ctx, request) var results []RegisteredModelInfo var totalCount int = 0 limit := request.MaxResults - iter := a.List(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -1839,6 +1784,7 @@ func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegistere } } return results, nil + } // RegisteredModelInfoNameToFullNameMap calls [RegisteredModelsAPI.ListAll] and creates a map of results with [RegisteredModelInfo].Name as key and [RegisteredModelInfo].FullName as value. @@ -2028,16 +1974,8 @@ func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) (it l } func (a *SchemasAPI) ListAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) { - var results []SchemaInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // SchemaInfoNameToFullNameMap calls [SchemasAPI.ListAll] and creates a map of results with [SchemaInfo].Name as key and [SchemaInfo].FullName as value. @@ -2218,16 +2156,8 @@ func (a *StorageCredentialsAPI) List(ctx context.Context) (it listing.Iterator[S } func (a *StorageCredentialsAPI) ListAll(ctx context.Context) ([]StorageCredentialInfo, error) { - var results []StorageCredentialInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // StorageCredentialInfoNameToIdMap calls [StorageCredentialsAPI.ListAll] and creates a map of results with [StorageCredentialInfo].Name as key and [StorageCredentialInfo].Id as value. @@ -2362,16 +2292,8 @@ func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRe } func (a *SystemSchemasAPI) ListAll(ctx context.Context, request ListSystemSchemasRequest) ([]SystemSchemaInfo, error) { - var results []SystemSchemaInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // List system schemas. @@ -2591,10 +2513,10 @@ func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) (it lis } func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { + iter := a.List(ctx, request) var results []TableInfo var totalCount int = 0 limit := request.MaxResults - iter := a.List(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -2607,6 +2529,7 @@ func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]T } } return results, nil + } // TableInfoNameToTableIdMap calls [TablesAPI.ListAll] and creates a map of results with [TableInfo].Name as key and [TableInfo].TableId as value. @@ -2703,10 +2626,10 @@ func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequ } func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesRequest) ([]TableSummary, error) { + iter := a.ListSummaries(ctx, request) var results []TableSummary var totalCount int = 0 limit := request.MaxResults - iter := a.ListSummaries(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -2719,6 +2642,7 @@ func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesR } } return results, nil + } // Update a table owner. @@ -2851,16 +2775,8 @@ func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) (it l } func (a *VolumesAPI) ListAll(ctx context.Context, request ListVolumesRequest) ([]VolumeInfo, error) { - var results []VolumeInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // VolumeInfoNameToVolumeIdMap calls [VolumesAPI.ListAll] and creates a map of results with [VolumeInfo].Name as key and [VolumeInfo].VolumeId as value. diff --git a/service/compute/api.go b/service/compute/api.go index 1fabf4a10..ffc0bf2c5 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -174,16 +174,8 @@ func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPolici } func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request ListClusterPoliciesRequest) ([]Policy, error) { - var results []Policy iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // PolicyNameToPolicyIdMap calls [ClusterPoliciesAPI.ListAll] and creates a map of results with [Policy].Name as key and [Policy].PolicyId as value. @@ -635,10 +627,10 @@ func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) (it listing } func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) { + iter := a.Events(ctx, request) var results []ClusterEvent var totalCount int64 = 0 limit := request.Limit - iter := a.Events(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -651,6 +643,7 @@ func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]Clust } } return results, nil + } // Get cluster info. @@ -738,16 +731,8 @@ func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) (it } func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) ([]ClusterDetails, error) { - var results []ClusterDetails iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // ClusterDetailsClusterNameToClusterIdMap calls [ClustersAPI.ListAll] and creates a map of results with [ClusterDetails].ClusterName as key and [ClusterDetails].ClusterId as value. @@ -1577,16 +1562,8 @@ func (a *GlobalInitScriptsAPI) List(ctx context.Context) (it listing.Iterator[Gl } func (a *GlobalInitScriptsAPI) ListAll(ctx context.Context) ([]GlobalInitScriptDetails, error) { - var results []GlobalInitScriptDetails iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // GlobalInitScriptDetailsNameToScriptIdMap calls [GlobalInitScriptsAPI.ListAll] and creates a map of results with [GlobalInitScriptDetails].Name as key and [GlobalInitScriptDetails].ScriptId as value. @@ -1802,16 +1779,8 @@ func (a *InstancePoolsAPI) List(ctx context.Context) (it listing.Iterator[Instan } func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, error) { - var results []InstancePoolAndStats iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap calls [InstancePoolsAPI.ListAll] and creates a map of results with [InstancePoolAndStats].InstancePoolName as key and [InstancePoolAndStats].InstancePoolId as value. @@ -1972,16 +1941,8 @@ func (a *InstanceProfilesAPI) List(ctx context.Context) (it listing.Iterator[Ins } func (a *InstanceProfilesAPI) ListAll(ctx context.Context) ([]InstanceProfile, error) { - var results []InstanceProfile iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Remove the instance profile. @@ -2101,16 +2062,8 @@ func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusR } func (a *LibrariesAPI) ClusterStatusAll(ctx context.Context, request ClusterStatusRequest) ([]LibraryFullStatus, error) { - var results []LibraryFullStatus iter := a.ClusterStatus(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Get status. @@ -2239,10 +2192,10 @@ func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamilies } func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamiliesRequest) ([]PolicyFamily, error) { + iter := a.List(ctx, request) var results []PolicyFamily var totalCount int64 = 0 limit := request.MaxResults - iter := a.List(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -2255,4 +2208,5 @@ func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamil } } return results, nil + } diff --git a/service/files/api.go b/service/files/api.go index fb5ea491f..a0228a92d 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -162,16 +162,8 @@ func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) (it listing } func (a *DbfsAPI) ListAll(ctx context.Context, request ListDbfsRequest) ([]FileInfo, error) { - var results []FileInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // List directory contents or file details. diff --git a/service/iam/api.go b/service/iam/api.go index e287e8465..715e57f5d 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -223,16 +223,8 @@ func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRe } func (a *AccountGroupsAPI) ListAll(ctx context.Context, request ListAccountGroupsRequest) ([]Group, error) { - var results []Group iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // GroupDisplayNameToIdMap calls [AccountGroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -400,16 +392,8 @@ func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAcco } func (a *AccountServicePrincipalsAPI) ListAll(ctx context.Context, request ListAccountServicePrincipalsRequest) ([]ServicePrincipal, error) { - var results []ServicePrincipal iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // ServicePrincipalDisplayNameToIdMap calls [AccountServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -586,16 +570,8 @@ func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequ } func (a *AccountUsersAPI) ListAll(ctx context.Context, request ListAccountUsersRequest) ([]User, error) { - var results []User iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // UserUserNameToIdMap calls [AccountUsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -799,16 +775,8 @@ func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) (it lis } func (a *GroupsAPI) ListAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { - var results []Group iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // GroupDisplayNameToIdMap calls [GroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -1101,16 +1069,8 @@ func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrin } func (a *ServicePrincipalsAPI) ListAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { - var results []ServicePrincipal iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // ServicePrincipalDisplayNameToIdMap calls [ServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -1302,16 +1262,8 @@ func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) (it listi } func (a *UsersAPI) ListAll(ctx context.Context, request ListUsersRequest) ([]User, error) { - var results []User iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // UserUserNameToIdMap calls [UsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -1489,16 +1441,8 @@ func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspace } func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorkspaceAssignmentRequest) ([]PermissionAssignment, error) { - var results []PermissionAssignment iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Get permission assignments. diff --git a/service/iam/model.go b/service/iam/model.go index f08919356..e65f2492f 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -1024,7 +1024,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Roles []ComplexValue `json:"roles,omitempty"` diff --git a/service/jobs/api.go b/service/jobs/api.go index a64e561a5..a4589e711 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -354,10 +354,10 @@ func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) (it listing } func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJob, error) { + iter := a.List(ctx, request) var results []BaseJob var totalCount int = 0 limit := request.Limit - iter := a.List(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -370,6 +370,7 @@ func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJ } } return results, nil + } // BaseJobSettingsNameToJobIdMap calls [JobsAPI.ListAll] and creates a map of results with [BaseJob].Settings.Name as key and [BaseJob].JobId as value. @@ -456,10 +457,10 @@ func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) (it lis } func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]BaseRun, error) { + iter := a.ListRuns(ctx, request) var results []BaseRun var totalCount int = 0 limit := request.Limit - iter := a.ListRuns(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -472,6 +473,7 @@ func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]B } } return results, nil + } // Repair a job run. diff --git a/service/ml/api.go b/service/ml/api.go index 4a34b84f7..353338187 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -153,10 +153,10 @@ func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryReque } func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRequest) ([]Metric, error) { + iter := a.GetHistory(ctx, request) var results []Metric var totalCount int = 0 limit := request.MaxResults - iter := a.GetHistory(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -169,6 +169,7 @@ func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRe } } return results, nil + } // Get experiment permission levels. @@ -249,16 +250,8 @@ func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifact } func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) { - var results []FileInfo iter := a.ListArtifacts(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // List experiments. @@ -292,10 +285,10 @@ func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperi } func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) { + iter := a.ListExperiments(ctx, request) var results []Experiment var totalCount int = 0 limit := request.MaxResults - iter := a.ListExperiments(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -308,6 +301,7 @@ func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExp } } return results, nil + } // Log a batch. @@ -446,16 +440,8 @@ func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchEx } func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) { - var results []Experiment iter := a.SearchExperiments(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Search for runs. @@ -491,16 +477,8 @@ func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) (it } func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) ([]Run, error) { - var results []Run iter := a.SearchRuns(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Set a tag. @@ -702,16 +680,8 @@ func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLat } func (a *ModelRegistryAPI) GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) { - var results []ModelVersion iter := a.GetLatestVersions(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Get model. @@ -805,10 +775,10 @@ func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsReq } func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModelsRequest) ([]Model, error) { + iter := a.ListModels(ctx, request) var results []Model var totalCount int = 0 limit := request.MaxResults - iter := a.ListModels(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -821,6 +791,7 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels } } return results, nil + } // List transition requests. @@ -848,16 +819,8 @@ func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request L } func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, request ListTransitionRequestsRequest) ([]Activity, error) { - var results []Activity iter := a.ListTransitionRequests(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // List registry webhooks. @@ -893,16 +856,8 @@ func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhook } func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebhooksRequest) ([]RegistryWebhook, error) { - var results []RegistryWebhook iter := a.ListWebhooks(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Reject a transition request. @@ -950,10 +905,10 @@ func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request Sear } func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) { + iter := a.SearchModelVersions(ctx, request) var results []ModelVersion var totalCount int = 0 limit := request.MaxResults - iter := a.SearchModelVersions(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -966,6 +921,7 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S } } return results, nil + } // Search models. @@ -999,10 +955,10 @@ func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModel } func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchModelsRequest) ([]Model, error) { + iter := a.SearchModels(ctx, request) var results []Model var totalCount int = 0 limit := request.MaxResults - iter := a.SearchModels(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -1015,6 +971,7 @@ func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchMo } } return results, nil + } // Set a tag. diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index 8675739f9..ff3c69793 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -75,37 +75,37 @@ func ExampleModelRegistryAPI_CreateModel_modelVersions() { } -func ExampleModelRegistryAPI_CreateModel_models() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", model) } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_models() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", model) + logger.Infof(ctx, "found %v", created) } diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 3347d17fb..0a409ce71 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -111,16 +111,8 @@ func (a *CustomAppIntegrationAPI) List(ctx context.Context) (it listing.Iterator } func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIntegrationOutput, error) { - var results []GetCustomAppIntegrationOutput iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Updates Custom OAuth App Integration. @@ -248,10 +240,10 @@ func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPubli } func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPublishedAppsRequest) ([]PublishedAppOutput, error) { + iter := a.List(ctx, request) var results []PublishedAppOutput var totalCount int64 = 0 limit := request.PageSize - iter := a.List(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -264,6 +256,7 @@ func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPu } } return results, nil + } func NewPublishedAppIntegration(client *client.DatabricksClient) *PublishedAppIntegrationAPI { @@ -366,16 +359,8 @@ func (a *PublishedAppIntegrationAPI) List(ctx context.Context) (it listing.Itera } func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishedAppIntegrationOutput, error) { - var results []GetPublishedAppIntegrationOutput iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Updates Published OAuth App Integration. @@ -476,16 +461,8 @@ func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServi } func (a *ServicePrincipalSecretsAPI) ListAll(ctx context.Context, request ListServicePrincipalSecretsRequest) ([]SecretInfo, error) { - var results []SecretInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // List service principal secrets. diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 7477482f5..0947ccabf 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -280,10 +280,10 @@ func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipel } func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPipelineEventsRequest) ([]PipelineEvent, error) { + iter := a.ListPipelineEvents(ctx, request) var results []PipelineEvent var totalCount int = 0 limit := request.MaxResults - iter := a.ListPipelineEvents(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -296,6 +296,7 @@ func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPi } } return results, nil + } // List pipeline events. @@ -338,10 +339,10 @@ func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesR } func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelinesRequest) ([]PipelineStateInfo, error) { + iter := a.ListPipelines(ctx, request) var results []PipelineStateInfo var totalCount int = 0 limit := request.MaxResults - iter := a.ListPipelines(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -354,6 +355,7 @@ func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelin } } return results, nil + } // PipelineStateInfoNameToPipelineIdMap calls [PipelinesAPI.ListPipelinesAll] and creates a map of results with [PipelineStateInfo].Name as key and [PipelineStateInfo].PipelineId as value. diff --git a/service/serving/api.go b/service/serving/api.go index ac587077f..2a272f9a2 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -274,16 +274,8 @@ func (a *ServingEndpointsAPI) List(ctx context.Context) (it listing.Iterator[Ser } func (a *ServingEndpointsAPI) ListAll(ctx context.Context) ([]ServingEndpoint, error) { - var results []ServingEndpoint iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Retrieve the most recent log lines associated with a given serving endpoint's diff --git a/service/settings/api.go b/service/settings/api.go index 86a305302..8899c5e01 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -138,16 +138,8 @@ func (a *AccountIpAccessListsAPI) List(ctx context.Context) (it listing.Iterator } func (a *AccountIpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { - var results []IpAccessListInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // IpAccessListInfoLabelToListIdMap calls [AccountIpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -459,16 +451,8 @@ func (a *IpAccessListsAPI) List(ctx context.Context) (it listing.Iterator[IpAcce } func (a *IpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { - var results []IpAccessListInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // IpAccessListInfoLabelToListIdMap calls [IpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -725,16 +709,8 @@ func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManageme } func (a *TokenManagementAPI) ListAll(ctx context.Context, request ListTokenManagementRequest) ([]TokenInfo, error) { - var results []TokenInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // TokenInfoCommentToTokenIdMap calls [TokenManagementAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. @@ -892,16 +868,8 @@ func (a *TokensAPI) List(ctx context.Context) (it listing.Iterator[TokenInfo]) { } func (a *TokensAPI) ListAll(ctx context.Context) ([]TokenInfo, error) { - var results []TokenInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // TokenInfoCommentToTokenIdMap calls [TokensAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. diff --git a/service/sharing/api.go b/service/sharing/api.go index f2c1a0bb2..14ef665d7 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -122,10 +122,10 @@ func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) } func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsRequest) ([]CleanRoomInfo, error) { + iter := a.List(ctx, request) var results []CleanRoomInfo var totalCount int = 0 limit := request.MaxResults - iter := a.List(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -138,6 +138,7 @@ func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsReque } } return results, nil + } // Update a clean room. @@ -264,16 +265,8 @@ func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) ( } func (a *ProvidersAPI) ListAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) { - var results []ProviderInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // ProviderInfoNameToMetastoreIdMap calls [ProvidersAPI.ListAll] and creates a map of results with [ProviderInfo].Name as key and [ProviderInfo].MetastoreId as value. @@ -328,16 +321,8 @@ func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest } func (a *ProvidersAPI) ListSharesAll(ctx context.Context, request ListSharesRequest) ([]ProviderShare, error) { - var results []ProviderShare iter := a.ListShares(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // List shares by Provider. @@ -549,16 +534,8 @@ func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) } func (a *RecipientsAPI) ListAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) { - var results []RecipientInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // RecipientInfoNameToMetastoreIdMap calls [RecipientsAPI.ListAll] and creates a map of results with [RecipientInfo].Name as key and [RecipientInfo].MetastoreId as value. @@ -726,16 +703,8 @@ func (a *SharesAPI) List(ctx context.Context) (it listing.Iterator[ShareInfo]) { } func (a *SharesAPI) ListAll(ctx context.Context) ([]ShareInfo, error) { - var results []ShareInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Get permissions. diff --git a/service/sql/api.go b/service/sql/api.go index 369e44d0f..42c9f551f 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -318,10 +318,10 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) } func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { + iter := a.List(ctx, request) var results []Dashboard var totalCount int = 0 limit := request.PageSize - iter := a.List(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -334,6 +334,7 @@ func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsReque } } return results, nil + } // DashboardNameToIdMap calls [DashboardsAPI.ListAll] and creates a map of results with [Dashboard].Name as key and [Dashboard].Id as value. @@ -689,10 +690,10 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) (it l } func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { + iter := a.List(ctx, request) var results []Query var totalCount int = 0 limit := request.PageSize - iter := a.List(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -705,6 +706,7 @@ func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([ } } return results, nil + } // QueryNameToIdMap calls [QueriesAPI.ListAll] and creates a map of results with [Query].Name as key and [Query].Id as value. @@ -837,10 +839,10 @@ func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequ } func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) { + iter := a.List(ctx, request) var results []QueryInfo var totalCount int = 0 limit := request.MaxResults - iter := a.List(ctx, request) for iter.HasNext(ctx) { next, err := iter.Next(ctx) if err != nil { @@ -853,6 +855,7 @@ func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryR } } return results, nil + } func NewQueryVisualizations(client *client.DatabricksClient) *QueryVisualizationsAPI { @@ -1441,16 +1444,8 @@ func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) } func (a *WarehousesAPI) ListAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) { - var results []EndpointInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // EndpointInfoNameToIdMap calls [WarehousesAPI.ListAll] and creates a map of results with [EndpointInfo].Name as key and [EndpointInfo].Id as value. diff --git a/service/workspace/api.go b/service/workspace/api.go index 4d8314ed3..0bb649804 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -113,16 +113,8 @@ func (a *GitCredentialsAPI) List(ctx context.Context) (it listing.Iterator[Crede } func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error) { - var results []CredentialInfo iter := a.List(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // CredentialInfoGitProviderToCredentialIdMap calls [GitCredentialsAPI.ListAll] and creates a map of results with [CredentialInfo].GitProvider as key and [CredentialInfo].CredentialId as value. @@ -328,16 +320,8 @@ func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) (it listi } func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error) { - var results []RepoInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // RepoInfoPathToIdMap calls [ReposAPI.ListAll] and creates a map of results with [RepoInfo].Path as key and [RepoInfo].Id as value. @@ -572,16 +556,8 @@ func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) (it } func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) { - var results []AclItem iter := a.ListAcls(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // Lists ACLs. @@ -627,16 +603,8 @@ func (a *SecretsAPI) ListScopes(ctx context.Context) (it listing.Iterator[Secret } func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { - var results []SecretScope iter := a.ListScopes(ctx) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // List secret keys. @@ -671,16 +639,8 @@ func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest } func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) { - var results []SecretMetadata iter := a.ListSecrets(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // List secret keys. @@ -908,16 +868,8 @@ func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) ( } func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error) { - var results []ObjectInfo iter := a.List(ctx, request) - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - } - return results, nil + return listing.ToSlice(ctx, iter) } // ObjectInfoPathToObjectIdMap calls [WorkspaceAPI.ListAll] and creates a map of results with [ObjectInfo].Path as key and [ObjectInfo].ObjectId as value. From 12b3895df7a27513282bde9a7f6b64ceda0ec586 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 16:15:20 +0200 Subject: [PATCH 13/24] fix test --- listing/listing_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/listing/listing_test.go b/listing/listing_test.go index 2d3d178c6..059a9450e 100644 --- a/listing/listing_test.go +++ b/listing/listing_test.go @@ -147,7 +147,7 @@ func TestDedupeIterator(t *testing.T) { }, ) - dedupeIterator := listing.NewDedupeIterator( + dedupeIterator := listing.NewDedupeIterator[int, int]( iterator, func(a int) int { return a }) for i := 1; i <= 6; i++ { @@ -187,7 +187,7 @@ func TestDedupeIterator(t *testing.T) { }, ) - dedupeIterator := listing.NewDedupeIterator( + dedupeIterator := listing.NewDedupeIterator[int, int]( iterator, func(a int) int { return a }) values := make([]int, 0) for dedupeIterator.HasNext(context.Background()) { From a94de22810a9516299ae8997e61aeb3525d23694 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 16:20:58 +0200 Subject: [PATCH 14/24] Do not export structs --- listing/listing.go | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/listing/listing.go b/listing/listing.go index 18f2f3c25..6b9fe7164 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -5,11 +5,26 @@ import ( "errors" ) +// Iterator[T] is an iterator over items of type T. It is similar to +// java.util.Iterator. It is not thread-safe. type Iterator[T any] interface { + // HasNext returns true if there are more items to iterate over. HasNext + // will also return true if the iterator needs to fetch the next page of + // items from the underlying source and the request fails, even if there + // are no more items to iterate over. In this case, Next will return the + // error. HasNext(context.Context) bool + + // Next returns the next item in the iterator. If there are no more items + // to iterate over, it returns ErrNoMoreItems. If there was an error + // fetching the next page of items, it returns that error. Once Next + // returns ErrNoMoreItems or an error, it will continue to return that + // error. Next(context.Context) (T, error) } +// ToSlice returns all items from the iterator as a slice. If there was an +// error fetching items at any time, it returns that error. func ToSlice[T any](ctx context.Context, it Iterator[T]) ([]T, error) { var items []T for it.HasNext(ctx) { @@ -22,8 +37,8 @@ func ToSlice[T any](ctx context.Context, it Iterator[T]) ([]T, error) { return items, nil } -// Use struct{} for Req to indicate one-shot iterator. -type IteratorImpl[Req, Resp, T any] struct { +// Use struct{} for Req for iterators that don't need any request structure. +type iteratorImpl[Req, Resp, T any] struct { // nextReq is the request to be used to fetch the next page. If nil, then // there is no next page to fetch. nextReq *Req @@ -51,13 +66,20 @@ type IteratorImpl[Req, Resp, T any] struct { var ErrNoMoreItems = errors.New("no more items") +// Returns a new iterator. The iterator will fetch the next page of items +// lazily, when needed. nextReq is the request to be used to fetch the initial +// page. If nil, then no page will be fetched. getNextPage fetches the next +// page of items, returning the deserialized response and error. getItems +// selects the items being iterated over from the response. getNextReq is used +// to get the next request to be used in the next page. If the returned value +// is nil, then there is no next page to fetch. func NewIterator[Req, Resp, T any]( nextReq *Req, getNextPage func(context.Context, Req) (Resp, error), getItems func(Resp) []T, getNextReq func(Resp) *Req, -) *IteratorImpl[Req, Resp, T] { - return &IteratorImpl[Req, Resp, T]{ +) *iteratorImpl[Req, Resp, T] { + return &iteratorImpl[Req, Resp, T]{ nextReq: nextReq, getNextPage: getNextPage, getItems: getItems, @@ -65,7 +87,7 @@ func NewIterator[Req, Resp, T any]( } } -func (i *IteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error { +func (i *iteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error { if i.currentPageIdx < len(i.currentPage) { return nil } @@ -95,7 +117,7 @@ func (i *IteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) e return nil } -func (i *IteratorImpl[Req, Resp, T]) Next(ctx context.Context) (T, error) { +func (i *iteratorImpl[Req, Resp, T]) Next(ctx context.Context) (T, error) { var t T err := i.loadNextPageIfNeeded(ctx) if err != nil { @@ -109,7 +131,7 @@ func (i *IteratorImpl[Req, Resp, T]) Next(ctx context.Context) (T, error) { return item, nil } -func (i *IteratorImpl[Req, Resp, T]) HasNext(ctx context.Context) bool { +func (i *iteratorImpl[Req, Resp, T]) HasNext(ctx context.Context) bool { err := i.loadNextPageIfNeeded(ctx) if err != nil { return true @@ -117,22 +139,22 @@ func (i *IteratorImpl[Req, Resp, T]) HasNext(ctx context.Context) bool { return i.currentPageIdx < len(i.currentPage) } -type DedupeIteratorImpl[T any, Id comparable] struct { +type dedupeIteratorImpl[T any, Id comparable] struct { it Iterator[T] getId func(T) Id seen map[Id]struct{} current *T } -func NewDedupeIterator[T any, Id comparable](it Iterator[T], getId func(T) Id) *DedupeIteratorImpl[T, Id] { - return &DedupeIteratorImpl[T, Id]{ +func NewDedupeIterator[T any, Id comparable](it Iterator[T], getId func(T) Id) *dedupeIteratorImpl[T, Id] { + return &dedupeIteratorImpl[T, Id]{ it: it, getId: getId, seen: make(map[Id]struct{}), } } -func (i *DedupeIteratorImpl[T, Id]) Next(ctx context.Context) (T, error) { +func (i *dedupeIteratorImpl[T, Id]) Next(ctx context.Context) (T, error) { if i.current != nil { t := *i.current i.current = nil @@ -151,7 +173,7 @@ func (i *DedupeIteratorImpl[T, Id]) Next(ctx context.Context) (T, error) { } } -func (i *DedupeIteratorImpl[T, Id]) HasNext(ctx context.Context) bool { +func (i *dedupeIteratorImpl[T, Id]) HasNext(ctx context.Context) bool { if i.current != nil { return true } From c148d22b9e0b0f2c9bab5ba2c04ab88a592dd8ad Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 16:32:07 +0200 Subject: [PATCH 15/24] bit more code coverage --- listing/listing_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/listing/listing_test.go b/listing/listing_test.go index 059a9450e..b88b65be6 100644 --- a/listing/listing_test.go +++ b/listing/listing_test.go @@ -37,7 +37,7 @@ func TestIterator(t *testing.T) { }, ) - for i := 1; i <= 6; i++ { + for i := 1; iterator.HasNext(context.Background()); i++ { item, err := iterator.Next(context.Background()) assert.NoError(t, err) assert.Equal(t, i, item) @@ -191,6 +191,7 @@ func TestDedupeIterator(t *testing.T) { iterator, func(a int) int { return a }) values := make([]int, 0) for dedupeIterator.HasNext(context.Background()) { + assert.True(t, dedupeIterator.HasNext(context.Background())) v, err := dedupeIterator.Next(context.Background()) values = append(values, v) assert.NoError(t, err) From b4e6106bfb2c93f81469f20333b30d0366a8f92f Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 16:49:51 +0200 Subject: [PATCH 16/24] bit more testing --- listing/listing_test.go | 166 ++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 99 deletions(-) diff --git a/listing/listing_test.go b/listing/listing_test.go index b88b65be6..5a5adf7b9 100644 --- a/listing/listing_test.go +++ b/listing/listing_test.go @@ -9,33 +9,47 @@ import ( "github.com/stretchr/testify/assert" ) +type requestResponse struct { + req string + page map[string][]int +} + +func makeIterator(reqsAndPages []requestResponse) listing.Iterator[int] { + reqs := make([]string, len(reqsAndPages)) + pages := make(map[string]map[string][]int) + for i, reqAndPage := range reqsAndPages { + reqs[i] = reqAndPage.req + pages[reqAndPage.req] = reqAndPage.page + } + nextReq := reqs[0] + iterator := listing.NewIterator(&nextReq, + func(ctx context.Context, req string) (map[string][]int, error) { + return pages[req], nil + }, + func(resp map[string][]int) []int { + return resp["page"] + }, + func(resp map[string][]int) *string { + for i, r := range reqs { + if r == nextReq && i+1 < len(reqs) { + nextReq = reqs[i+1] + return &nextReq + } + } + return nil + }, + ) + return iterator +} + func TestIterator(t *testing.T) { t.Run("basic iteration", func(t *testing.T) { - reqs := []string{"page1", "page2", "page3"} - pages := map[string]map[string][]int{ - "page1": {"page": {1, 2}}, - "page2": {"page": {3, 4}}, - "page3": {"page": {5, 6}}, + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 6}}}, } - nextReq := "page1" - - iterator := listing.NewIterator(&nextReq, - func(ctx context.Context, req string) (map[string][]int, error) { - return pages[req], nil - }, - func(resp map[string][]int) []int { - return resp["page"] - }, - func(resp map[string][]int) *string { - for i, r := range reqs { - if r == nextReq && i+1 < len(reqs) { - nextReq = reqs[i+1] - return &nextReq - } - } - return nil - }, - ) + iterator := makeIterator(rrs) for i := 1; iterator.HasNext(context.Background()); i++ { item, err := iterator.Next(context.Background()) @@ -82,31 +96,12 @@ func TestIterator(t *testing.T) { }) t.Run("iteration with empty page in the middle", func(t *testing.T) { - reqs := []string{"page1", "page2", "page3"} - pages := map[string]map[string][]int{ - "page1": {"page": {1, 2}}, - "page2": {"page": {}}, - "page3": {"page": {3, 4}}, + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {}}}, + {req: "page3", page: map[string][]int{"page": {3, 4}}}, } - nextReq := "page1" - - iterator := listing.NewIterator(&nextReq, - func(ctx context.Context, req string) (map[string][]int, error) { - return pages[req], nil - }, - func(resp map[string][]int) []int { - return resp["page"] - }, - func(resp map[string][]int) *string { - for i, r := range reqs { - if r == nextReq && i+1 < len(reqs) { - nextReq = reqs[i+1] - return &nextReq - } - } - return nil - }, - ) + iterator := makeIterator(rrs) for i := 1; i <= 4; i++ { item, err := iterator.Next(context.Background()) @@ -121,32 +116,12 @@ func TestIterator(t *testing.T) { func TestDedupeIterator(t *testing.T) { t.Run("basic iteration", func(t *testing.T) { - reqs := []string{"page1", "page2", "page3"} - pages := map[string][]int{ - "page1": {1, 2, 2}, - "page2": {3, 4, 4}, - "page3": {5, 5, 6}, + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 5, 6}}}, } - nextReq := "page1" - - iterator := listing.NewIterator(&nextReq, - func(ctx context.Context, req string) ([]int, error) { - return pages[req], nil - }, - func(resp []int) []int { - return resp - }, - func(resp []int) *string { - for i, r := range reqs { - if r == nextReq && i+1 < len(reqs) { - nextReq = reqs[i+1] - return &nextReq - } - } - return nil - }, - ) - + iterator := makeIterator(rrs) dedupeIterator := listing.NewDedupeIterator[int, int]( iterator, func(a int) int { return a }) @@ -161,34 +136,15 @@ func TestDedupeIterator(t *testing.T) { }) t.Run("HasNext caches appropriately", func(t *testing.T) { - reqs := []string{"page1", "page2", "page3"} - pages := map[string][]int{ - "page1": {1, 2, 2}, - "page2": {3, 4, 4}, - "page3": {5, 5, 6}, + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 5, 6}}}, } - nextReq := "page1" - - iterator := listing.NewIterator(&nextReq, - func(ctx context.Context, req string) ([]int, error) { - return pages[req], nil - }, - func(resp []int) []int { - return resp - }, - func(resp []int) *string { - for i, r := range reqs { - if r == nextReq && i+1 < len(reqs) { - nextReq = reqs[i+1] - return &nextReq - } - } - return nil - }, - ) - + iterator := makeIterator(rrs) dedupeIterator := listing.NewDedupeIterator[int, int]( iterator, func(a int) int { return a }) + values := make([]int, 0) for dedupeIterator.HasNext(context.Background()) { assert.True(t, dedupeIterator.HasNext(context.Background())) @@ -200,6 +156,18 @@ func TestDedupeIterator(t *testing.T) { }) t.Run("HasNext returns true when there is an error", func(t *testing.T) { - + expectedErr := errors.New("some error") + iterator := listing.NewIterator[struct{}, []int, int](&struct{}{}, + func(ctx context.Context, req struct{}) ([]int, error) { + return nil, expectedErr + }, + nil, + nil, + ) + dedupeIterator := listing.NewDedupeIterator[int, int]( + iterator, func(a int) int { return a }) + assert.True(t, dedupeIterator.HasNext(context.Background())) + _, err := dedupeIterator.Next(context.Background()) + assert.ErrorIs(t, err, expectedErr) }) } From e6b65bf585fa9dca8006d600d62b2176a07f941c Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 16:54:49 +0200 Subject: [PATCH 17/24] empty page at end --- listing/listing_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/listing/listing_test.go b/listing/listing_test.go index 5a5adf7b9..ee38c58ba 100644 --- a/listing/listing_test.go +++ b/listing/listing_test.go @@ -112,6 +112,24 @@ func TestIterator(t *testing.T) { _, err := iterator.Next(context.Background()) assert.ErrorIs(t, err, listing.ErrNoMoreItems) }) + + t.Run("iteration with empty page at the end", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + {req: "page3", page: map[string][]int{"page": {}}}, + } + iterator := makeIterator(rrs) + + for i := 1; i <= 4; i++ { + item, err := iterator.Next(context.Background()) + assert.NoError(t, err) + assert.Equal(t, i, item) + } + + _, err := iterator.Next(context.Background()) + assert.ErrorIs(t, err, listing.ErrNoMoreItems) + }) } func TestDedupeIterator(t *testing.T) { From a1cff39a18e9b99fea3f2f898dcdf366bf0d17b7 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 17:02:34 +0200 Subject: [PATCH 18/24] comments --- listing/listing.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/listing/listing.go b/listing/listing.go index 6b9fe7164..dfa0c76a4 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -133,6 +133,9 @@ func (i *iteratorImpl[Req, Resp, T]) Next(ctx context.Context) (T, error) { func (i *iteratorImpl[Req, Resp, T]) HasNext(ctx context.Context) bool { err := i.loadNextPageIfNeeded(ctx) + // As described in the documentation for HasNext, if there was an error + // fetching the next page, we still return true to allow the user to handle + // the error in Next. if err != nil { return true } @@ -177,6 +180,11 @@ func (i *dedupeIteratorImpl[T, Id]) HasNext(ctx context.Context) bool { if i.current != nil { return true } + // To compute HasNext in dedupeIteratorImpl, we need to actually fetch the + // next item from the underlying iterator and compare it to seen items. + // However, the retrieved item cannot be discarded, as it needs to be + // returned by the next call to Next. So we store the item in current and + // return it in the next call to Next, after which current is set to nil. for { t, err := i.it.Next(ctx) if errors.Is(err, ErrNoMoreItems) { From 9acc5f9c95302f7a83e5c7fcca3557a5ab526d10 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Fri, 20 Oct 2023 17:11:34 +0200 Subject: [PATCH 19/24] comments --- listing/listing.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/listing/listing.go b/listing/listing.go index dfa0c76a4..2329c4a5c 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -103,16 +103,15 @@ func (i *iteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) e // Keep loading pages while we have a next request and the current page is // empty. i.currentPage = nil + i.currentPageIdx = 0 for i.nextReq != nil && len(i.currentPage) == 0 { resp, err := i.getNextPage(ctx, *i.nextReq) i.lastErr = err if err != nil { return err } - items := i.getItems(resp) - i.currentPage = items - i.currentPageIdx = 0 i.nextReq = i.getNextReq(resp) + i.currentPage = i.getItems(resp) } return nil } From 62ba8e4bcca28ef46e35b47daa7f15b6768c9ddf Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Mon, 23 Oct 2023 09:23:58 +0200 Subject: [PATCH 20/24] Add ToSliceN and expose Iterator types --- .codegen/api.go.tmpl | 47 +-- listing/listing.go | 39 ++- listing/listing_test.go | 26 ++ service/billing/api.go | 34 ++- service/catalog/api.go | 369 ++++++++++++++---------- service/compute/api.go | 185 +++++++----- service/files/api.go | 26 +- service/iam/api.go | 113 +++++--- service/iam/model.go | 2 +- service/jobs/api.go | 60 ++-- service/ml/api.go | 252 ++++++++-------- service/ml/model_registry_usage_test.go | 26 +- service/oauth2/api.go | 82 +++--- service/pipelines/api.go | 60 ++-- service/serving/api.go | 14 +- service/settings/api.go | 64 ++-- service/sharing/api.go | 106 ++++--- service/sql/api.go | 115 +++----- service/sql/model.go | 1 + service/workspace/api.go | 115 +++++--- 20 files changed, 974 insertions(+), 762 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 9e0b69fd4..06c939696 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -163,12 +163,12 @@ func (a *{{.Service.Name}}API) {{.PascalName}}AndWait(ctx context.Context{{if .R {{.Comment "// " 80}} // // This method is generated by Databricks SDK Code Generator. -func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) (it listing.Iterator[{{template "type" .Pagination.Entity}}]) { +func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) {{ template "paginated-return-type" . }} { {{ if not .Request }}request := struct{}{}{{end}} {{if eq .Pagination.Increment 1 -}} request.{{.Pagination.Offset.PascalName}} = 1 // start iterating from the first page {{end}} - getNextPage := func(ctx context.Context, req {{if .Request}}{{.Request.PascalName}}{{else}}struct{}{{end}}) (*{{ .Response.PascalName }}, error) { + getNextPage := func(ctx context.Context, req {{ template "paginated-request-type" . }}) (*{{ .Response.PascalName }}, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") return a.impl.{{.PascalName}}(ctx{{if .Request}}, req{{end}}) } @@ -199,41 +199,32 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} return &request } {{- end}} - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, {{if .Pagination.MultiRequest}}getNextReq{{else}}nil{{end}}) {{ if .NeedsOffsetDedupe -}} - it = listing.NewDedupeIterator( - it, + dedupedIterator := listing.NewDedupeIterator( + iterator, func(item {{ template "type" .Pagination.Entity }}) {{ template "type" .IdentifierField.Entity }} { return item{{ template "field-path" .IdFieldPath }} }) + return dedupedIterator + {{- else -}} + return iterator {{- end }} - return it } +{{.Comment "// " 80}} +// +// This method is generated by Databricks SDK Code Generator. func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{ template "type" .Pagination.Entity }}, error) { - iter := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) + iterator := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) {{ if .Pagination.Limit -}} - var results []{{ template "type" .Pagination.Entity }} - var totalCount {{template "type" .Pagination.Limit.Entity}} = 0 - limit := request.{{.Pagination.Limit.PascalName}} - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + return listing.ToSliceN(ctx, iterator, request.{{.Pagination.Limit.PascalName}}) {{ else -}} - return listing.ToSlice(ctx, iter) + return listing.ToSlice(ctx, iterator) {{- end }} } {{end}}{{if .NamedIdMap}} @@ -310,4 +301,14 @@ func (a *{{.Service.Name}}API) {{.Shortcut.PascalName}}AndWait(ctx context.Conte {{- end}} {{- define "field-path" -}} {{- range .}}.{{.PascalName}}{{end}} +{{- end -}} +{{- define "paginated-request-type" -}} + {{if .Request}}{{.Request.PascalName}}{{else}}struct{}{{end}} +{{- end -}} +{{- define "paginated-return-type" -}} + {{ if .NeedsOffsetDedupe -}} + *listing.DedupeIteratorImpl[{{ template "type" .Pagination.Entity }}, {{ template "type" .IdentifierField.Entity }}] + {{- else -}} + *listing.IteratorImpl[{{ template "paginated-request-type" .}}, *{{ .Response.PascalName }}, {{ template "type" .Pagination.Entity }}] + {{- end -}} {{- end -}} \ No newline at end of file diff --git a/listing/listing.go b/listing/listing.go index 2329c4a5c..05e30c2a5 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -37,8 +37,22 @@ func ToSlice[T any](ctx context.Context, it Iterator[T]) ([]T, error) { return items, nil } +// ToSliceN returns the first N items from the iterator as a slice. If there +// was an error fetching items at any time, it returns that error. +func ToSliceN[T any, Limit ~int | ~int64](ctx context.Context, it Iterator[T], n Limit) ([]T, error) { + var items []T + for it.HasNext(ctx) && Limit(len(items)) < n { + item, err := it.Next(ctx) + if err != nil { + return nil, err + } + items = append(items, item) + } + return items, nil +} + // Use struct{} for Req for iterators that don't need any request structure. -type iteratorImpl[Req, Resp, T any] struct { +type IteratorImpl[Req, Resp, T any] struct { // nextReq is the request to be used to fetch the next page. If nil, then // there is no next page to fetch. nextReq *Req @@ -78,8 +92,8 @@ func NewIterator[Req, Resp, T any]( getNextPage func(context.Context, Req) (Resp, error), getItems func(Resp) []T, getNextReq func(Resp) *Req, -) *iteratorImpl[Req, Resp, T] { - return &iteratorImpl[Req, Resp, T]{ +) *IteratorImpl[Req, Resp, T] { + return &IteratorImpl[Req, Resp, T]{ nextReq: nextReq, getNextPage: getNextPage, getItems: getItems, @@ -87,7 +101,7 @@ func NewIterator[Req, Resp, T any]( } } -func (i *iteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error { +func (i *IteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error { if i.currentPageIdx < len(i.currentPage) { return nil } @@ -104,6 +118,9 @@ func (i *iteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) e // empty. i.currentPage = nil i.currentPageIdx = 0 + // Endpoints using token-based pagination may return an empty page with a + // next token. We need to keep fetching pages until we get a non-empty + // page or there are no more pages. for i.nextReq != nil && len(i.currentPage) == 0 { resp, err := i.getNextPage(ctx, *i.nextReq) i.lastErr = err @@ -116,7 +133,7 @@ func (i *iteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) e return nil } -func (i *iteratorImpl[Req, Resp, T]) Next(ctx context.Context) (T, error) { +func (i *IteratorImpl[Req, Resp, T]) Next(ctx context.Context) (T, error) { var t T err := i.loadNextPageIfNeeded(ctx) if err != nil { @@ -130,7 +147,7 @@ func (i *iteratorImpl[Req, Resp, T]) Next(ctx context.Context) (T, error) { return item, nil } -func (i *iteratorImpl[Req, Resp, T]) HasNext(ctx context.Context) bool { +func (i *IteratorImpl[Req, Resp, T]) HasNext(ctx context.Context) bool { err := i.loadNextPageIfNeeded(ctx) // As described in the documentation for HasNext, if there was an error // fetching the next page, we still return true to allow the user to handle @@ -141,22 +158,22 @@ func (i *iteratorImpl[Req, Resp, T]) HasNext(ctx context.Context) bool { return i.currentPageIdx < len(i.currentPage) } -type dedupeIteratorImpl[T any, Id comparable] struct { +type DedupeIteratorImpl[T any, Id comparable] struct { it Iterator[T] getId func(T) Id seen map[Id]struct{} current *T } -func NewDedupeIterator[T any, Id comparable](it Iterator[T], getId func(T) Id) *dedupeIteratorImpl[T, Id] { - return &dedupeIteratorImpl[T, Id]{ +func NewDedupeIterator[T any, Id comparable](it Iterator[T], getId func(T) Id) *DedupeIteratorImpl[T, Id] { + return &DedupeIteratorImpl[T, Id]{ it: it, getId: getId, seen: make(map[Id]struct{}), } } -func (i *dedupeIteratorImpl[T, Id]) Next(ctx context.Context) (T, error) { +func (i *DedupeIteratorImpl[T, Id]) Next(ctx context.Context) (T, error) { if i.current != nil { t := *i.current i.current = nil @@ -175,7 +192,7 @@ func (i *dedupeIteratorImpl[T, Id]) Next(ctx context.Context) (T, error) { } } -func (i *dedupeIteratorImpl[T, Id]) HasNext(ctx context.Context) bool { +func (i *DedupeIteratorImpl[T, Id]) HasNext(ctx context.Context) bool { if i.current != nil { return true } diff --git a/listing/listing_test.go b/listing/listing_test.go index ee38c58ba..9893d5e28 100644 --- a/listing/listing_test.go +++ b/listing/listing_test.go @@ -130,6 +130,32 @@ func TestIterator(t *testing.T) { _, err := iterator.Next(context.Background()) assert.ErrorIs(t, err, listing.ErrNoMoreItems) }) + + t.Run("ToSlice returns all items", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 6}}}, + } + iterator := makeIterator(rrs) + + items, err := listing.ToSlice(context.Background(), iterator) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2, 3, 4, 5, 6}, items) + }) + + t.Run("ToSliceN returns the first N items", func(t *testing.T) { + rrs := []requestResponse{ + {req: "page1", page: map[string][]int{"page": {1, 2}}}, + {req: "page2", page: map[string][]int{"page": {3, 4}}}, + {req: "page3", page: map[string][]int{"page": {5, 6}}}, + } + iterator := makeIterator(rrs) + + items, err := listing.ToSliceN(context.Background(), iterator, 3) + assert.NoError(t, err) + assert.Equal(t, []int{1, 2, 3}, items) + }) } func TestDedupeIterator(t *testing.T) { diff --git a/service/billing/api.go b/service/billing/api.go index 18f1250e8..e6361bd47 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -131,7 +131,7 @@ func (a *BudgetsAPI) GetByBudgetId(ctx context.Context, budgetId string) (*Wrapp // for each day that the budget is configured to include. // // This method is generated by Databricks SDK Code Generator. -func (a *BudgetsAPI) List(ctx context.Context) (it listing.Iterator[BudgetWithStatus]) { +func (a *BudgetsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *BudgetList, BudgetWithStatus] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*BudgetList, error) { @@ -142,18 +142,23 @@ func (a *BudgetsAPI) List(ctx context.Context) (it listing.Iterator[BudgetWithSt return resp.Budgets } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get all budgets. +// +// Gets all budgets associated with this account, including noncumulative status +// for each day that the budget is configured to include. +// +// This method is generated by Databricks SDK Code Generator. func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // BudgetWithStatusNameToBudgetIdMap calls [BudgetsAPI.ListAll] and creates a map of results with [BudgetWithStatus].Name as key and [BudgetWithStatus].BudgetId as value. @@ -359,7 +364,7 @@ func (a *LogDeliveryAPI) GetByLogDeliveryConfigurationId(ctx context.Context, lo // specified by ID. // // This method is generated by Databricks SDK Code Generator. -func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryRequest) (it listing.Iterator[LogDeliveryConfiguration]) { +func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryRequest) *listing.IteratorImpl[ListLogDeliveryRequest, *WrappedLogDeliveryConfigurations, LogDeliveryConfiguration] { getNextPage := func(ctx context.Context, req ListLogDeliveryRequest) (*WrappedLogDeliveryConfigurations, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -369,18 +374,23 @@ func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryReques return resp.LogDeliveryConfigurations } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get all log delivery configurations. +// +// Gets all Databricks log delivery configurations associated with an account +// specified by ID. +// +// This method is generated by Databricks SDK Code Generator. func (a *LogDeliveryAPI) ListAll(ctx context.Context, request ListLogDeliveryRequest) ([]LogDeliveryConfiguration, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // LogDeliveryConfigurationConfigNameToConfigIdMap calls [LogDeliveryAPI.ListAll] and creates a map of results with [LogDeliveryConfiguration].ConfigName as key and [LogDeliveryConfiguration].ConfigId as value. diff --git a/service/catalog/api.go b/service/catalog/api.go index 1aca8e216..49b988cfa 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -93,7 +93,7 @@ func (a *AccountMetastoreAssignmentsAPI) GetByWorkspaceId(ctx context.Context, w // metastore. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) (it listing.Iterator[int64]) { +func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) *listing.IteratorImpl[ListAccountMetastoreAssignmentsRequest, *ListAccountMetastoreAssignmentsResponse, int64] { getNextPage := func(ctx context.Context, req ListAccountMetastoreAssignmentsRequest) (*ListAccountMetastoreAssignmentsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -103,18 +103,23 @@ func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListA return resp.WorkspaceIds } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get all workspaces assigned to a metastore. +// +// Gets a list of all Databricks workspace IDs that have been assigned to given +// metastore. +// +// This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoreAssignmentsAPI) ListAll(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) ([]int64, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // Get all workspaces assigned to a metastore. @@ -207,7 +212,7 @@ func (a *AccountMetastoresAPI) GetByMetastoreId(ctx context.Context, metastoreId // Gets all Unity Catalog metastores associated with an account specified by ID. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountMetastoresAPI) List(ctx context.Context) (it listing.Iterator[MetastoreInfo]) { +func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListMetastoresResponse, MetastoreInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { @@ -218,18 +223,22 @@ func (a *AccountMetastoresAPI) List(ctx context.Context) (it listing.Iterator[Me return resp.Metastores } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get all metastores associated with an account. +// +// Gets all Unity Catalog metastores associated with an account specified by ID. +// +// This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // Update a metastore. @@ -545,7 +554,7 @@ func (a *CatalogsAPI) GetByName(ctx context.Context, name string) (*CatalogInfo, // the array. // // This method is generated by Databricks SDK Code Generator. -func (a *CatalogsAPI) List(ctx context.Context) (it listing.Iterator[CatalogInfo]) { +func (a *CatalogsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListCatalogsResponse, CatalogInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListCatalogsResponse, error) { @@ -556,18 +565,26 @@ func (a *CatalogsAPI) List(ctx context.Context) (it listing.Iterator[CatalogInfo return resp.Catalogs } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List catalogs. +// +// Gets an array of catalogs in the metastore. If the caller is the metastore +// admin, all catalogs will be retrieved. Otherwise, only catalogs owned by the +// caller (or for which the caller has the **USE_CATALOG** privilege) will be +// retrieved. There is no guarantee of a specific ordering of the elements in +// the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *CatalogsAPI) ListAll(ctx context.Context) ([]CatalogInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // Update a catalog. @@ -664,7 +681,7 @@ func (a *ConnectionsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Con // List all connections. // // This method is generated by Databricks SDK Code Generator. -func (a *ConnectionsAPI) List(ctx context.Context) (it listing.Iterator[ConnectionInfo]) { +func (a *ConnectionsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListConnectionsResponse, ConnectionInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListConnectionsResponse, error) { @@ -675,18 +692,22 @@ func (a *ConnectionsAPI) List(ctx context.Context) (it listing.Iterator[Connecti return resp.Connections } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List connections. +// +// List all connections. +// +// This method is generated by Databricks SDK Code Generator. func (a *ConnectionsAPI) ListAll(ctx context.Context) ([]ConnectionInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // ConnectionInfoNameToFullNameMap calls [ConnectionsAPI.ListAll] and creates a map of results with [ConnectionInfo].Name as key and [ConnectionInfo].FullName as value. @@ -844,7 +865,7 @@ func (a *ExternalLocationsAPI) GetByName(ctx context.Context, name string) (*Ext // array. // // This method is generated by Databricks SDK Code Generator. -func (a *ExternalLocationsAPI) List(ctx context.Context) (it listing.Iterator[ExternalLocationInfo]) { +func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListExternalLocationsResponse, ExternalLocationInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListExternalLocationsResponse, error) { @@ -855,18 +876,26 @@ func (a *ExternalLocationsAPI) List(ctx context.Context) (it listing.Iterator[Ex return resp.ExternalLocations } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List external locations. +// +// Gets an array of external locations (__ExternalLocationInfo__ objects) from +// the metastore. The caller must be a metastore admin, the owner of the +// external location, or a user that has some privilege on the external +// location. There is no guarantee of a specific ordering of the elements in the +// array. +// +// This method is generated by Databricks SDK Code Generator. func (a *ExternalLocationsAPI) ListAll(ctx context.Context) ([]ExternalLocationInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // Update an external location. @@ -988,7 +1017,7 @@ func (a *FunctionsAPI) GetByName(ctx context.Context, name string) (*FunctionInf // the array. // // This method is generated by Databricks SDK Code Generator. -func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) (it listing.Iterator[FunctionInfo]) { +func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) *listing.IteratorImpl[ListFunctionsRequest, *ListFunctionsResponse, FunctionInfo] { getNextPage := func(ctx context.Context, req ListFunctionsRequest) (*ListFunctionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -998,18 +1027,28 @@ func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) ( return resp.Functions } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List functions. +// +// List functions within the specified parent catalog and schema. If the user is +// a metastore admin, all functions are returned in the output list. Otherwise, +// the user must have the **USE_CATALOG** privilege on the catalog and the +// **USE_SCHEMA** privilege on the schema, and the output list contains only +// functions for which either the user has the **EXECUTE** privilege or the user +// is the owner. There is no guarantee of a specific ordering of the elements in +// the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *FunctionsAPI) ListAll(ctx context.Context, request ListFunctionsRequest) ([]FunctionInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // FunctionInfoNameToFullNameMap calls [FunctionsAPI.ListAll] and creates a map of results with [FunctionInfo].Name as key and [FunctionInfo].FullName as value. @@ -1240,7 +1279,7 @@ func (a *MetastoresAPI) GetById(ctx context.Context, id string) (*MetastoreInfo, // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *MetastoresAPI) List(ctx context.Context) (it listing.Iterator[MetastoreInfo]) { +func (a *MetastoresAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListMetastoresResponse, MetastoreInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { @@ -1251,18 +1290,24 @@ func (a *MetastoresAPI) List(ctx context.Context) (it listing.Iterator[Metastore return resp.Metastores } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List metastores. +// +// Gets an array of the available metastores (as __MetastoreInfo__ objects). The +// caller must be an admin to retrieve this info. There is no guarantee of a +// specific ordering of the elements in the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *MetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // MetastoreInfoNameToMetastoreIdMap calls [MetastoresAPI.ListAll] and creates a map of results with [MetastoreInfo].Name as key and [MetastoreInfo].MetastoreId as value. @@ -1493,7 +1538,7 @@ func (a *ModelVersionsAPI) GetByAliasByFullNameAndAlias(ctx context.Context, ful // There is no guarantee of a specific ordering of the elements in the response. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRequest) (it listing.Iterator[ModelVersionInfo]) { +func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRequest) *listing.IteratorImpl[ListModelVersionsRequest, *ListModelVersionsResponse, ModelVersionInfo] { getNextPage := func(ctx context.Context, req ListModelVersionsRequest) (*ListModelVersionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1509,32 +1554,33 @@ func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRe request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List Model Versions. +// +// List model versions. You can list model versions under a particular schema, +// or list all model versions in the current metastore. +// +// The returned models are filtered based on the privileges of the calling user. +// For example, the metastore admin is able to list all the model versions. A +// regular user needs to be the owner or have the **EXECUTE** privilege on the +// parent registered model to recieve the model versions in the response. For +// the latter case, the caller must also be the owner or have the +// **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** +// privilege on the parent schema. +// +// There is no guarantee of a specific ordering of the elements in the response. +// +// This method is generated by Databricks SDK Code Generator. func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersionsRequest) ([]ModelVersionInfo, error) { - iter := a.List(ctx, request) - var results []ModelVersionInfo - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.List(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -1742,7 +1788,7 @@ func (a *RegisteredModelsAPI) GetByFullName(ctx context.Context, fullName string // There is no guarantee of a specific ordering of the elements in the response. // // This method is generated by Databricks SDK Code Generator. -func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) (it listing.Iterator[RegisteredModelInfo]) { +func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) *listing.IteratorImpl[ListRegisteredModelsRequest, *ListRegisteredModelsResponse, RegisteredModelInfo] { getNextPage := func(ctx context.Context, req ListRegisteredModelsRequest) (*ListRegisteredModelsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1758,32 +1804,33 @@ func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredMo request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List Registered Models. +// +// List registered models. You can list registered models under a particular +// schema, or list all registered models in the current metastore. +// +// The returned models are filtered based on the privileges of the calling user. +// For example, the metastore admin is able to list all the registered models. A +// regular user needs to be the owner or have the **EXECUTE** privilege on the +// registered model to recieve the registered models in the response. For the +// latter case, the caller must also be the owner or have the **USE_CATALOG** +// privilege on the parent catalog and the **USE_SCHEMA** privilege on the +// parent schema. +// +// There is no guarantee of a specific ordering of the elements in the response. +// +// This method is generated by Databricks SDK Code Generator. func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegisteredModelsRequest) ([]RegisteredModelInfo, error) { - iter := a.List(ctx, request) - var results []RegisteredModelInfo - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.List(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -1954,7 +2001,7 @@ func (a *SchemasAPI) GetByFullName(ctx context.Context, fullName string) (*Schem // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) (it listing.Iterator[SchemaInfo]) { +func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *listing.IteratorImpl[ListSchemasRequest, *ListSchemasResponse, SchemaInfo] { getNextPage := func(ctx context.Context, req ListSchemasRequest) (*ListSchemasResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1964,18 +2011,26 @@ func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) (it l return resp.Schemas } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List schemas. +// +// Gets an array of schemas for a catalog in the metastore. If the caller is the +// metastore admin or the owner of the parent catalog, all schemas for the +// catalog will be retrieved. Otherwise, only schemas owned by the caller (or +// for which the caller has the **USE_SCHEMA** privilege) will be retrieved. +// There is no guarantee of a specific ordering of the elements in the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *SchemasAPI) ListAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // SchemaInfoNameToFullNameMap calls [SchemasAPI.ListAll] and creates a map of results with [SchemaInfo].Name as key and [SchemaInfo].FullName as value. @@ -2135,7 +2190,7 @@ func (a *StorageCredentialsAPI) GetByName(ctx context.Context, name string) (*St // of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *StorageCredentialsAPI) List(ctx context.Context) (it listing.Iterator[StorageCredentialInfo]) { +func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListStorageCredentialsResponse, StorageCredentialInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListStorageCredentialsResponse, error) { @@ -2146,18 +2201,26 @@ func (a *StorageCredentialsAPI) List(ctx context.Context) (it listing.Iterator[S return resp.StorageCredentials } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List credentials. +// +// Gets an array of storage credentials (as __StorageCredentialInfo__ objects). +// The array is limited to only those storage credentials the caller has +// permission to access. If the caller is a metastore admin, all storage +// credentials will be retrieved. There is no guarantee of a specific ordering +// of the elements in the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *StorageCredentialsAPI) ListAll(ctx context.Context) ([]StorageCredentialInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // StorageCredentialInfoNameToIdMap calls [StorageCredentialsAPI.ListAll] and creates a map of results with [StorageCredentialInfo].Name as key and [StorageCredentialInfo].Id as value. @@ -2272,7 +2335,7 @@ func (a *SystemSchemasAPI) Enable(ctx context.Context, request EnableRequest) er // account admin or a metastore admin. // // This method is generated by Databricks SDK Code Generator. -func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRequest) (it listing.Iterator[SystemSchemaInfo]) { +func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRequest) *listing.IteratorImpl[ListSystemSchemasRequest, *ListSystemSchemasResponse, SystemSchemaInfo] { getNextPage := func(ctx context.Context, req ListSystemSchemasRequest) (*ListSystemSchemasResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2282,18 +2345,23 @@ func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRe return resp.Schemas } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List system schemas. +// +// Gets an array of system schemas for a metastore. The caller must be an +// account admin or a metastore admin. +// +// This method is generated by Databricks SDK Code Generator. func (a *SystemSchemasAPI) ListAll(ctx context.Context, request ListSystemSchemasRequest) ([]SystemSchemaInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // List system schemas. @@ -2487,7 +2555,7 @@ func (a *TablesAPI) GetByFullName(ctx context.Context, fullName string) (*TableI // guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) (it listing.Iterator[TableInfo]) { +func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listing.IteratorImpl[ListTablesRequest, *ListTablesResponse, TableInfo] { getNextPage := func(ctx context.Context, req ListTablesRequest) (*ListTablesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2503,32 +2571,27 @@ func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) (it lis request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List tables. +// +// Gets an array of all tables for the current metastore under the parent +// catalog and schema. The caller must be a metastore admin or an owner of (or +// have the **SELECT** privilege on) the table. For the latter case, the caller +// must also be the owner or have the **USE_CATALOG** privilege on the parent +// catalog and the **USE_SCHEMA** privilege on the parent schema. There is no +// guarantee of a specific ordering of the elements in the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { - iter := a.List(ctx, request) - var results []TableInfo - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.List(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -2600,7 +2663,7 @@ func (a *TablesAPI) GetByName(ctx context.Context, name string) (*TableInfo, err // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequest) (it listing.Iterator[TableSummary]) { +func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequest) *listing.IteratorImpl[ListSummariesRequest, *ListTableSummariesResponse, TableSummary] { getNextPage := func(ctx context.Context, req ListSummariesRequest) (*ListTableSummariesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2616,32 +2679,32 @@ func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequ request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List table summaries. +// +// Gets an array of summaries for tables for a schema and catalog within the +// metastore. The table summaries returned are either: +// +// * summaries for all tables (within the current metastore and parent catalog +// and schema), when the user is a metastore admin, or: * summaries for all +// tables and schemas (within the current metastore and parent catalog) for +// which the user has ownership or the **SELECT** privilege on the table and +// ownership or **USE_SCHEMA** privilege on the schema, provided that the user +// also has ownership or the **USE_CATALOG** privilege on the parent catalog. +// +// There is no guarantee of a specific ordering of the elements in the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesRequest) ([]TableSummary, error) { - iter := a.ListSummaries(ctx, request) - var results []TableSummary - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.ListSummaries(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -2755,7 +2818,7 @@ func (a *VolumesAPI) DeleteByFullNameArg(ctx context.Context, fullNameArg string // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) (it listing.Iterator[VolumeInfo]) { +func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *listing.IteratorImpl[ListVolumesRequest, *ListVolumesResponseContent, VolumeInfo] { getNextPage := func(ctx context.Context, req ListVolumesRequest) (*ListVolumesResponseContent, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2765,18 +2828,32 @@ func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) (it l return resp.Volumes } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List Volumes. +// +// Gets an array of all volumes for the current metastore under the parent +// catalog and schema. +// +// The returned volumes are filtered based on the privileges of the calling +// user. For example, the metastore admin is able to list all the volumes. A +// regular user needs to be the owner or have the **READ VOLUME** privilege on +// the volume to recieve the volumes in the response. For the latter case, the +// caller must also be the owner or have the **USE_CATALOG** privilege on the +// parent catalog and the **USE_SCHEMA** privilege on the parent schema. +// +// There is no guarantee of a specific ordering of the elements in the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *VolumesAPI) ListAll(ctx context.Context, request ListVolumesRequest) ([]VolumeInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // VolumeInfoNameToVolumeIdMap calls [VolumesAPI.ListAll] and creates a map of results with [VolumeInfo].Name as key and [VolumeInfo].VolumeId as value. diff --git a/service/compute/api.go b/service/compute/api.go index ffc0bf2c5..315e4ed91 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -154,7 +154,7 @@ func (a *ClusterPoliciesAPI) GetPermissionsByClusterPolicyId(ctx context.Context // Returns a list of policies accessible by the requesting user. // // This method is generated by Databricks SDK Code Generator. -func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPoliciesRequest) (it listing.Iterator[Policy]) { +func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPoliciesRequest) *listing.IteratorImpl[ListClusterPoliciesRequest, *ListPoliciesResponse, Policy] { getNextPage := func(ctx context.Context, req ListClusterPoliciesRequest) (*ListPoliciesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -164,18 +164,22 @@ func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPolici return resp.Policies } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List cluster policies. +// +// Returns a list of policies accessible by the requesting user. +// +// This method is generated by Databricks SDK Code Generator. func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request ListClusterPoliciesRequest) ([]Policy, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // PolicyNameToPolicyIdMap calls [ClusterPoliciesAPI.ListAll] and creates a map of results with [Policy].Name as key and [Policy].PolicyId as value. @@ -600,7 +604,7 @@ func (a *ClustersAPI) EditAndWait(ctx context.Context, editCluster EditCluster, // nparameters necessary to request the next page of events. // // This method is generated by Databricks SDK Code Generator. -func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) (it listing.Iterator[ClusterEvent]) { +func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.IteratorImpl[GetEvents, *GetEventsResponse, ClusterEvent] { getNextPage := func(ctx context.Context, req GetEvents) (*GetEventsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -617,32 +621,24 @@ func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) (it listing return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List cluster activity events. +// +// Retrieves a list of events about the activity of a cluster. This API is +// paginated. If there are more events to read, the response includes all the +// nparameters necessary to request the next page of events. +// +// This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) { - iter := a.Events(ctx, request) - var results []ClusterEvent - var totalCount int64 = 0 - limit := request.Limit - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.Events(ctx, request) + return listing.ToSliceN(ctx, iterator, request.Limit) } @@ -711,7 +707,7 @@ func (a *ClustersAPI) GetPermissionsByClusterId(ctx context.Context, clusterId s // terminated job clusters. // // This method is generated by Databricks SDK Code Generator. -func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) (it listing.Iterator[ClusterDetails]) { +func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *listing.IteratorImpl[ListClustersRequest, *ListClustersResponse, ClusterDetails] { getNextPage := func(ctx context.Context, req ListClustersRequest) (*ListClustersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -721,18 +717,30 @@ func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) (it return resp.Clusters } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List all clusters. +// +// Return information about all pinned clusters, active clusters, up to 200 of +// the most recently terminated all-purpose clusters in the past 30 days, and up +// to 30 of the most recently terminated job clusters in the past 30 days. +// +// For example, if there is 1 pinned cluster, 4 active clusters, 45 terminated +// all-purpose clusters in the past 30 days, and 50 terminated job clusters in +// the past 30 days, then this API returns the 1 pinned cluster, 4 active +// clusters, all 45 terminated all-purpose clusters, and the 30 most recently +// terminated job clusters. +// +// This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) ([]ClusterDetails, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // ClusterDetailsClusterNameToClusterIdMap calls [ClustersAPI.ListAll] and creates a map of results with [ClusterDetails].ClusterName as key and [ClusterDetails].ClusterId as value. @@ -1541,7 +1549,7 @@ func (a *GlobalInitScriptsAPI) GetByScriptId(ctx context.Context, scriptId strin // script](#operation/get-script) operation. // // This method is generated by Databricks SDK Code Generator. -func (a *GlobalInitScriptsAPI) List(ctx context.Context) (it listing.Iterator[GlobalInitScriptDetails]) { +func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListGlobalInitScriptsResponse, GlobalInitScriptDetails] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListGlobalInitScriptsResponse, error) { @@ -1552,18 +1560,25 @@ func (a *GlobalInitScriptsAPI) List(ctx context.Context) (it listing.Iterator[Gl return resp.Scripts } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get init scripts. +// +// Get a list of all global init scripts for this workspace. This returns all +// properties for each script but **not** the script contents. To retrieve the +// contents of a script, use the [get a global init +// script](#operation/get-script) operation. +// +// This method is generated by Databricks SDK Code Generator. func (a *GlobalInitScriptsAPI) ListAll(ctx context.Context) ([]GlobalInitScriptDetails, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // GlobalInitScriptDetailsNameToScriptIdMap calls [GlobalInitScriptsAPI.ListAll] and creates a map of results with [GlobalInitScriptDetails].Name as key and [GlobalInitScriptDetails].ScriptId as value. @@ -1758,7 +1773,7 @@ func (a *InstancePoolsAPI) GetPermissionsByInstancePoolId(ctx context.Context, i // Gets a list of instance pools with their statistics. // // This method is generated by Databricks SDK Code Generator. -func (a *InstancePoolsAPI) List(ctx context.Context) (it listing.Iterator[InstancePoolAndStats]) { +func (a *InstancePoolsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListInstancePools, InstancePoolAndStats] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListInstancePools, error) { @@ -1769,18 +1784,22 @@ func (a *InstancePoolsAPI) List(ctx context.Context) (it listing.Iterator[Instan return resp.InstancePools } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List instance pool info. +// +// Gets a list of instance pools with their statistics. +// +// This method is generated by Databricks SDK Code Generator. func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap calls [InstancePoolsAPI.ListAll] and creates a map of results with [InstancePoolAndStats].InstancePoolName as key and [InstancePoolAndStats].InstancePoolId as value. @@ -1920,7 +1939,7 @@ func (a *InstanceProfilesAPI) Edit(ctx context.Context, request InstanceProfile) // This API is available to all users. // // This method is generated by Databricks SDK Code Generator. -func (a *InstanceProfilesAPI) List(ctx context.Context) (it listing.Iterator[InstanceProfile]) { +func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListInstanceProfilesResponse, InstanceProfile] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListInstanceProfilesResponse, error) { @@ -1931,18 +1950,24 @@ func (a *InstanceProfilesAPI) List(ctx context.Context) (it listing.Iterator[Ins return resp.InstanceProfiles } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List available instance profiles. +// +// List the instance profiles that the calling user can use to launch a cluster. +// +// This API is available to all users. +// +// This method is generated by Databricks SDK Code Generator. func (a *InstanceProfilesAPI) ListAll(ctx context.Context) ([]InstanceProfile, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // Remove the instance profile. @@ -2042,7 +2067,7 @@ func (a *LibrariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterL // guarantee. // // This method is generated by Databricks SDK Code Generator. -func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) (it listing.Iterator[LibraryFullStatus]) { +func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) *listing.IteratorImpl[ClusterStatusRequest, *ClusterLibraryStatuses, LibraryFullStatus] { getNextPage := func(ctx context.Context, req ClusterStatusRequest) (*ClusterLibraryStatuses, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2052,18 +2077,36 @@ func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusR return resp.LibraryStatuses } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get status. +// +// Get the status of libraries on a cluster. A status will be available for all +// libraries installed on this cluster via the API or the libraries UI as well +// as libraries set to be installed on all clusters via the libraries UI. The +// order of returned libraries will be as follows. +// +// 1. Libraries set to be installed on this cluster will be returned first. +// Within this group, the final order will be order in which the libraries were +// added to the cluster. +// +// 2. Libraries set to be installed on all clusters are returned next. Within +// this group there is no order guarantee. +// +// 3. Libraries that were previously requested on this cluster or on all +// clusters, but now marked for removal. Within this group there is no order +// guarantee. +// +// This method is generated by Databricks SDK Code Generator. func (a *LibrariesAPI) ClusterStatusAll(ctx context.Context, request ClusterStatusRequest) ([]LibraryFullStatus, error) { - iter := a.ClusterStatus(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.ClusterStatus(ctx, request) + return listing.ToSlice(ctx, iterator) } // Get status. @@ -2166,7 +2209,7 @@ func (a *PolicyFamiliesAPI) GetByPolicyFamilyId(ctx context.Context, policyFamil // Retrieve a list of policy families. This API is paginated. // // This method is generated by Databricks SDK Code Generator. -func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamiliesRequest) (it listing.Iterator[PolicyFamily]) { +func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamiliesRequest) *listing.IteratorImpl[ListPolicyFamiliesRequest, *ListPolicyFamiliesResponse, PolicyFamily] { getNextPage := func(ctx context.Context, req ListPolicyFamiliesRequest) (*ListPolicyFamiliesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2182,31 +2225,21 @@ func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamilies request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List policy families. +// +// Retrieve a list of policy families. This API is paginated. +// +// This method is generated by Databricks SDK Code Generator. func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamiliesRequest) ([]PolicyFamily, error) { - iter := a.List(ctx, request) - var results []PolicyFamily - var totalCount int64 = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.List(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } diff --git a/service/files/api.go b/service/files/api.go index a0228a92d..60f61945a 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -142,7 +142,7 @@ func (a *DbfsAPI) GetStatusByPath(ctx context.Context, path string) (*FileInfo, // which provides the same functionality without timing out. // // This method is generated by Databricks SDK Code Generator. -func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) (it listing.Iterator[FileInfo]) { +func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.IteratorImpl[ListDbfsRequest, *ListStatusResponse, FileInfo] { getNextPage := func(ctx context.Context, req ListDbfsRequest) (*ListStatusResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -152,18 +152,32 @@ func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) (it listing return resp.Files } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List directory contents or file details. +// +// List the contents of a directory, or details of the file. If the file or +// directory does not exist, this call throws an exception with +// `RESOURCE_DOES_NOT_EXIST`. +// +// When calling list on a large directory, the list operation will time out +// after approximately 60 seconds. We strongly recommend using list only on +// directories containing less than 10K files and discourage using the DBFS REST +// API for operations that list more than 10K files. Instead, we recommend that +// you perform such operations in the context of a cluster, using the [File +// system utility (dbutils.fs)](/dev-tools/databricks-utils.html#dbutils-fs), +// which provides the same functionality without timing out. +// +// This method is generated by Databricks SDK Code Generator. func (a *DbfsAPI) ListAll(ctx context.Context, request ListDbfsRequest) ([]FileInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // List directory contents or file details. diff --git a/service/iam/api.go b/service/iam/api.go index 715e57f5d..30e9503d7 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -203,7 +203,7 @@ func (a *AccountGroupsAPI) GetById(ctx context.Context, id string) (*Group, erro // Gets all details of the groups associated with the Databricks account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRequest) (it listing.Iterator[Group]) { +func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRequest) *listing.IteratorImpl[ListAccountGroupsRequest, *ListGroupsResponse, Group] { getNextPage := func(ctx context.Context, req ListAccountGroupsRequest) (*ListGroupsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -213,18 +213,22 @@ func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRe return resp.Resources } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List group details. +// +// Gets all details of the groups associated with the Databricks account. +// +// This method is generated by Databricks SDK Code Generator. func (a *AccountGroupsAPI) ListAll(ctx context.Context, request ListAccountGroupsRequest) ([]Group, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // GroupDisplayNameToIdMap calls [AccountGroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -372,7 +376,7 @@ func (a *AccountServicePrincipalsAPI) GetById(ctx context.Context, id string) (* // Gets the set of service principals associated with a Databricks account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAccountServicePrincipalsRequest) (it listing.Iterator[ServicePrincipal]) { +func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAccountServicePrincipalsRequest) *listing.IteratorImpl[ListAccountServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { getNextPage := func(ctx context.Context, req ListAccountServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -382,18 +386,22 @@ func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAcco return resp.Resources } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List service principals. +// +// Gets the set of service principals associated with a Databricks account. +// +// This method is generated by Databricks SDK Code Generator. func (a *AccountServicePrincipalsAPI) ListAll(ctx context.Context, request ListAccountServicePrincipalsRequest) ([]ServicePrincipal, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // ServicePrincipalDisplayNameToIdMap calls [AccountServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -550,7 +558,7 @@ func (a *AccountUsersAPI) GetById(ctx context.Context, id string) (*User, error) // Gets details for all the users associated with a Databricks account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequest) (it listing.Iterator[User]) { +func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequest) *listing.IteratorImpl[ListAccountUsersRequest, *ListUsersResponse, User] { getNextPage := func(ctx context.Context, req ListAccountUsersRequest) (*ListUsersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -560,18 +568,22 @@ func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequ return resp.Resources } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List users. +// +// Gets details for all the users associated with a Databricks account. +// +// This method is generated by Databricks SDK Code Generator. func (a *AccountUsersAPI) ListAll(ctx context.Context, request ListAccountUsersRequest) ([]User, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // UserUserNameToIdMap calls [AccountUsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -755,7 +767,7 @@ func (a *GroupsAPI) GetById(ctx context.Context, id string) (*Group, error) { // Gets all details of the groups associated with the Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) (it listing.Iterator[Group]) { +func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listing.IteratorImpl[ListGroupsRequest, *ListGroupsResponse, Group] { getNextPage := func(ctx context.Context, req ListGroupsRequest) (*ListGroupsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -765,18 +777,22 @@ func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) (it lis return resp.Resources } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List group details. +// +// Gets all details of the groups associated with the Databricks workspace. +// +// This method is generated by Databricks SDK Code Generator. func (a *GroupsAPI) ListAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // GroupDisplayNameToIdMap calls [GroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -1049,7 +1065,7 @@ func (a *ServicePrincipalsAPI) GetById(ctx context.Context, id string) (*Service // Gets the set of service principals associated with a Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrincipalsRequest) (it listing.Iterator[ServicePrincipal]) { +func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrincipalsRequest) *listing.IteratorImpl[ListServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { getNextPage := func(ctx context.Context, req ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1059,18 +1075,22 @@ func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrin return resp.Resources } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List service principals. +// +// Gets the set of service principals associated with a Databricks workspace. +// +// This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalsAPI) ListAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // ServicePrincipalDisplayNameToIdMap calls [ServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -1242,7 +1262,7 @@ func (a *UsersAPI) GetPermissions(ctx context.Context) (*PasswordPermissions, er // Gets details for all the users associated with a Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) (it listing.Iterator[User]) { +func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing.IteratorImpl[ListUsersRequest, *ListUsersResponse, User] { getNextPage := func(ctx context.Context, req ListUsersRequest) (*ListUsersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1252,18 +1272,22 @@ func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) (it listi return resp.Resources } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List users. +// +// Gets details for all the users associated with a Databricks workspace. +// +// This method is generated by Databricks SDK Code Generator. func (a *UsersAPI) ListAll(ctx context.Context, request ListUsersRequest) ([]User, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // UserUserNameToIdMap calls [UsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -1421,7 +1445,7 @@ func (a *WorkspaceAssignmentAPI) GetByWorkspaceId(ctx context.Context, workspace // Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspaceAssignmentRequest) (it listing.Iterator[PermissionAssignment]) { +func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspaceAssignmentRequest) *listing.IteratorImpl[ListWorkspaceAssignmentRequest, *PermissionAssignments, PermissionAssignment] { getNextPage := func(ctx context.Context, req ListWorkspaceAssignmentRequest) (*PermissionAssignments, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1431,18 +1455,23 @@ func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspace return resp.PermissionAssignments } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get permission assignments. +// +// Get the permission assignments for the specified Databricks account and +// Databricks workspace. +// +// This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorkspaceAssignmentRequest) ([]PermissionAssignment, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // Get permission assignments. diff --git a/service/iam/model.go b/service/iam/model.go index e65f2492f..8a1ba4cd1 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -1070,7 +1070,7 @@ type User struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks user ID. - Id string `json:"id,omitempty" url:"-"` + Id string `json:"id,omitempty"` Name *Name `json:"name,omitempty"` diff --git a/service/jobs/api.go b/service/jobs/api.go index a4589e711..4feab9bb3 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -328,7 +328,7 @@ func (a *JobsAPI) GetRunOutputByRunId(ctx context.Context, runId int64) (*RunOut // Retrieves a list of jobs. // // This method is generated by Databricks SDK Code Generator. -func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) (it listing.Iterator[BaseJob]) { +func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.IteratorImpl[ListJobsRequest, *ListJobsResponse, BaseJob] { getNextPage := func(ctx context.Context, req ListJobsRequest) (*ListJobsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -344,32 +344,22 @@ func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) (it listing request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List jobs. +// +// Retrieves a list of jobs. +// +// This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJob, error) { - iter := a.List(ctx, request) - var results []BaseJob - var totalCount int = 0 - limit := request.Limit - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.List(ctx, request) + return listing.ToSliceN(ctx, iterator, request.Limit) } @@ -431,7 +421,7 @@ func (a *JobsAPI) GetBySettingsName(ctx context.Context, name string) (*BaseJob, // List runs in descending order by start time. // // This method is generated by Databricks SDK Code Generator. -func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) (it listing.Iterator[BaseRun]) { +func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listing.IteratorImpl[ListRunsRequest, *ListRunsResponse, BaseRun] { getNextPage := func(ctx context.Context, req ListRunsRequest) (*ListRunsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -447,32 +437,22 @@ func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) (it lis request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List job runs. +// +// List runs in descending order by start time. +// +// This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]BaseRun, error) { - iter := a.ListRuns(ctx, request) - var results []BaseRun - var totalCount int = 0 - limit := request.Limit - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.ListRuns(ctx, request) + return listing.ToSliceN(ctx, iterator, request.Limit) } diff --git a/service/ml/api.go b/service/ml/api.go index 353338187..34fb9a9f9 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -127,7 +127,7 @@ func (a *ExperimentsAPI) GetExperiment(ctx context.Context, request GetExperimen // Gets a list of all values for the specified metric for a given run. // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) (it listing.Iterator[Metric]) { +func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) *listing.IteratorImpl[GetHistoryRequest, *GetMetricHistoryResponse, Metric] { getNextPage := func(ctx context.Context, req GetHistoryRequest) (*GetMetricHistoryResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -143,32 +143,22 @@ func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryReque request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// Get history of a given metric within a run. +// +// Gets a list of all values for the specified metric for a given run. +// +// This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRequest) ([]Metric, error) { - iter := a.GetHistory(ctx, request) - var results []Metric - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.GetHistory(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -224,7 +214,7 @@ func (a *ExperimentsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Ge // specified, the response contains only artifacts with the specified prefix.", // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifactsRequest) (it listing.Iterator[FileInfo]) { +func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifactsRequest) *listing.IteratorImpl[ListArtifactsRequest, *ListArtifactsResponse, FileInfo] { getNextPage := func(ctx context.Context, req ListArtifactsRequest) (*ListArtifactsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -240,18 +230,23 @@ func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifact request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// Get all artifacts. +// +// List artifacts for a run. Takes an optional `artifact_path` prefix. If it is +// specified, the response contains only artifacts with the specified prefix.", +// +// This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) { - iter := a.ListArtifacts(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.ListArtifacts(ctx, request) + return listing.ToSlice(ctx, iterator) } // List experiments. @@ -259,7 +254,7 @@ func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtif // Gets a list of all experiments. // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperimentsRequest) (it listing.Iterator[Experiment]) { +func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperimentsRequest) *listing.IteratorImpl[ListExperimentsRequest, *ListExperimentsResponse, Experiment] { getNextPage := func(ctx context.Context, req ListExperimentsRequest) (*ListExperimentsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -275,32 +270,22 @@ func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperi request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List experiments. +// +// Gets a list of all experiments. +// +// This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) { - iter := a.ListExperiments(ctx, request) - var results []Experiment - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.ListExperiments(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -414,7 +399,7 @@ func (a *ExperimentsAPI) RestoreRuns(ctx context.Context, request RestoreRuns) ( // Searches for experiments that satisfy specified search criteria. // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchExperiments) (it listing.Iterator[Experiment]) { +func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchExperiments) *listing.IteratorImpl[SearchExperiments, *SearchExperimentsResponse, Experiment] { getNextPage := func(ctx context.Context, req SearchExperiments) (*SearchExperimentsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -430,18 +415,22 @@ func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchEx request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// Search experiments. +// +// Searches for experiments that satisfy specified search criteria. +// +// This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) { - iter := a.SearchExperiments(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.SearchExperiments(ctx, request) + return listing.ToSlice(ctx, iterator) } // Search for runs. @@ -451,7 +440,7 @@ func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request Searc // Search expressions can use `mlflowMetric` and `mlflowParam` keys.", // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) (it listing.Iterator[Run]) { +func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *listing.IteratorImpl[SearchRuns, *SearchRunsResponse, Run] { getNextPage := func(ctx context.Context, req SearchRuns) (*SearchRunsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -467,18 +456,24 @@ func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) (it request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// Search for runs. +// +// Searches for runs that satisfy expressions. +// +// Search expressions can use `mlflowMetric` and `mlflowParam` keys.", +// +// This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) ([]Run, error) { - iter := a.SearchRuns(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.SearchRuns(ctx, request) + return listing.ToSlice(ctx, iterator) } // Set a tag. @@ -660,7 +655,7 @@ func (a *ModelRegistryAPI) DeleteWebhook(ctx context.Context, request DeleteWebh // Gets the latest version of a registered model. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) (it listing.Iterator[ModelVersion]) { +func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) *listing.IteratorImpl[GetLatestVersionsRequest, *GetLatestVersionsResponse, ModelVersion] { getNextPage := func(ctx context.Context, req GetLatestVersionsRequest) (*GetLatestVersionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -670,18 +665,22 @@ func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLat return resp.ModelVersions } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get the latest version. +// +// Gets the latest version of a registered model. +// +// This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) { - iter := a.GetLatestVersions(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.GetLatestVersions(ctx, request) + return listing.ToSlice(ctx, iterator) } // Get model. @@ -749,7 +748,7 @@ func (a *ModelRegistryAPI) GetPermissionsByRegisteredModelId(ctx context.Context // __max_results__. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsRequest) (it listing.Iterator[Model]) { +func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsRequest) *listing.IteratorImpl[ListModelsRequest, *ListModelsResponse, Model] { getNextPage := func(ctx context.Context, req ListModelsRequest) (*ListModelsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -765,32 +764,23 @@ func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsReq request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List models. +// +// Lists all available registered models, up to the limit specified in +// __max_results__. +// +// This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModelsRequest) ([]Model, error) { - iter := a.ListModels(ctx, request) - var results []Model - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.ListModels(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -799,7 +789,7 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels // Gets a list of all open stage transition requests for the model version. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request ListTransitionRequestsRequest) (it listing.Iterator[Activity]) { +func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request ListTransitionRequestsRequest) *listing.IteratorImpl[ListTransitionRequestsRequest, *ListTransitionRequestsResponse, Activity] { getNextPage := func(ctx context.Context, req ListTransitionRequestsRequest) (*ListTransitionRequestsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -809,18 +799,22 @@ func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request L return resp.Requests } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List transition requests. +// +// Gets a list of all open stage transition requests for the model version. +// +// This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, request ListTransitionRequestsRequest) ([]Activity, error) { - iter := a.ListTransitionRequests(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.ListTransitionRequests(ctx, request) + return listing.ToSlice(ctx, iterator) } // List registry webhooks. @@ -830,7 +824,7 @@ func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, reques // Lists all registry webhooks. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhooksRequest) (it listing.Iterator[RegistryWebhook]) { +func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhooksRequest) *listing.IteratorImpl[ListWebhooksRequest, *ListRegistryWebhooks, RegistryWebhook] { getNextPage := func(ctx context.Context, req ListWebhooksRequest) (*ListRegistryWebhooks, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -846,18 +840,24 @@ func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhook request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List registry webhooks. +// +// **NOTE:** This endpoint is in Public Preview. +// +// Lists all registry webhooks. +// +// This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebhooksRequest) ([]RegistryWebhook, error) { - iter := a.ListWebhooks(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.ListWebhooks(ctx, request) + return listing.ToSlice(ctx, iterator) } // Reject a transition request. @@ -879,7 +879,7 @@ func (a *ModelRegistryAPI) RenameModel(ctx context.Context, request RenameModelR // Searches for specific model versions based on the supplied __filter__. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request SearchModelVersionsRequest) (it listing.Iterator[ModelVersion]) { +func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request SearchModelVersionsRequest) *listing.IteratorImpl[SearchModelVersionsRequest, *SearchModelVersionsResponse, ModelVersion] { getNextPage := func(ctx context.Context, req SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -895,32 +895,22 @@ func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request Sear request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// Searches model versions. +// +// Searches for specific model versions based on the supplied __filter__. +// +// This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) { - iter := a.SearchModelVersions(ctx, request) - var results []ModelVersion - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.SearchModelVersions(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -929,7 +919,7 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S // Search for registered models based on the specified __filter__. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModelsRequest) (it listing.Iterator[Model]) { +func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModelsRequest) *listing.IteratorImpl[SearchModelsRequest, *SearchModelsResponse, Model] { getNextPage := func(ctx context.Context, req SearchModelsRequest) (*SearchModelsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -945,32 +935,22 @@ func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModel request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// Search models. +// +// Search for registered models based on the specified __filter__. +// +// This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchModelsRequest) ([]Model, error) { - iter := a.SearchModels(ctx, request) - var results []Model - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.SearchModels(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index ff3c69793..b5ccf9028 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -58,24 +58,24 @@ func ExampleModelRegistryAPI_CreateComment_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_modelVersions() { +func ExampleModelRegistryAPI_CreateModel_models() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", model) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -92,24 +92,24 @@ func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_models() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", model) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -124,18 +124,18 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { } logger.Infof(ctx, "found %v", model) - created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", mv) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -150,14 +150,14 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { } logger.Infof(ctx, "found %v", model) - mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", mv) + logger.Infof(ctx, "found %v", created) } diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 0a409ce71..1f1a38add 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -90,7 +90,7 @@ func (a *CustomAppIntegrationAPI) GetByIntegrationId(ctx context.Context, integr // account // // This method is generated by Databricks SDK Code Generator. -func (a *CustomAppIntegrationAPI) List(ctx context.Context) (it listing.Iterator[GetCustomAppIntegrationOutput]) { +func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *GetCustomAppIntegrationsOutput, GetCustomAppIntegrationOutput] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetCustomAppIntegrationsOutput, error) { @@ -101,18 +101,23 @@ func (a *CustomAppIntegrationAPI) List(ctx context.Context) (it listing.Iterator return resp.Apps } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get custom oauth app integrations. +// +// Get the list of custom oauth app integrations for the specified Databricks +// account +// +// This method is generated by Databricks SDK Code Generator. func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIntegrationOutput, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // Updates Custom OAuth App Integration. @@ -214,7 +219,7 @@ func (a *OAuthPublishedAppsAPI) Impl() OAuthPublishedAppsService { // Get all the available published OAuth apps in Databricks. // // This method is generated by Databricks SDK Code Generator. -func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPublishedAppsRequest) (it listing.Iterator[PublishedAppOutput]) { +func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPublishedAppsRequest) *listing.IteratorImpl[ListOAuthPublishedAppsRequest, *GetPublishedAppsOutput, PublishedAppOutput] { getNextPage := func(ctx context.Context, req ListOAuthPublishedAppsRequest) (*GetPublishedAppsOutput, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -230,32 +235,22 @@ func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPubli request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// Get all the published OAuth apps. +// +// Get all the available published OAuth apps in Databricks. +// +// This method is generated by Databricks SDK Code Generator. func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPublishedAppsRequest) ([]PublishedAppOutput, error) { - iter := a.List(ctx, request) - var results []PublishedAppOutput - var totalCount int64 = 0 - limit := request.PageSize - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.List(ctx, request) + return listing.ToSliceN(ctx, iterator, request.PageSize) } @@ -338,7 +333,7 @@ func (a *PublishedAppIntegrationAPI) GetByIntegrationId(ctx context.Context, int // account // // This method is generated by Databricks SDK Code Generator. -func (a *PublishedAppIntegrationAPI) List(ctx context.Context) (it listing.Iterator[GetPublishedAppIntegrationOutput]) { +func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *GetPublishedAppIntegrationsOutput, GetPublishedAppIntegrationOutput] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetPublishedAppIntegrationsOutput, error) { @@ -349,18 +344,23 @@ func (a *PublishedAppIntegrationAPI) List(ctx context.Context) (it listing.Itera return resp.Apps } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get published oauth app integrations. +// +// Get the list of published oauth app integrations for the specified Databricks +// account +// +// This method is generated by Databricks SDK Code Generator. func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishedAppIntegrationOutput, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // Updates Published OAuth App Integration. @@ -441,7 +441,7 @@ func (a *ServicePrincipalSecretsAPI) DeleteByServicePrincipalIdAndSecretId(ctx c // the secret values. // // This method is generated by Databricks SDK Code Generator. -func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServicePrincipalSecretsRequest) (it listing.Iterator[SecretInfo]) { +func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServicePrincipalSecretsRequest) *listing.IteratorImpl[ListServicePrincipalSecretsRequest, *ListServicePrincipalSecretsResponse, SecretInfo] { getNextPage := func(ctx context.Context, req ListServicePrincipalSecretsRequest) (*ListServicePrincipalSecretsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -451,18 +451,24 @@ func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServi return resp.Secrets } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List service principal secrets. +// +// List all secrets associated with the given service principal. This operation +// only returns information about the secrets themselves and does not include +// the secret values. +// +// This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalSecretsAPI) ListAll(ctx context.Context, request ListServicePrincipalSecretsRequest) ([]SecretInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // List service principal secrets. diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 0947ccabf..8362253f5 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -254,7 +254,7 @@ func (a *PipelinesAPI) GetUpdateByPipelineIdAndUpdateId(ctx context.Context, pip // Retrieves events for a pipeline. // // This method is generated by Databricks SDK Code Generator. -func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipelineEventsRequest) (it listing.Iterator[PipelineEvent]) { +func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipelineEventsRequest) *listing.IteratorImpl[ListPipelineEventsRequest, *ListPipelineEventsResponse, PipelineEvent] { getNextPage := func(ctx context.Context, req ListPipelineEventsRequest) (*ListPipelineEventsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -270,32 +270,22 @@ func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipel request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List pipeline events. +// +// Retrieves events for a pipeline. +// +// This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPipelineEventsRequest) ([]PipelineEvent, error) { - iter := a.ListPipelineEvents(ctx, request) - var results []PipelineEvent - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.ListPipelineEvents(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -313,7 +303,7 @@ func (a *PipelinesAPI) ListPipelineEventsByPipelineId(ctx context.Context, pipel // Lists pipelines defined in the Delta Live Tables system. // // This method is generated by Databricks SDK Code Generator. -func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesRequest) (it listing.Iterator[PipelineStateInfo]) { +func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesRequest) *listing.IteratorImpl[ListPipelinesRequest, *ListPipelinesResponse, PipelineStateInfo] { getNextPage := func(ctx context.Context, req ListPipelinesRequest) (*ListPipelinesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -329,32 +319,22 @@ func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesR request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List pipelines. +// +// Lists pipelines defined in the Delta Live Tables system. +// +// This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelinesRequest) ([]PipelineStateInfo, error) { - iter := a.ListPipelines(ctx, request) - var results []PipelineStateInfo - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.ListPipelines(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } diff --git a/service/serving/api.go b/service/serving/api.go index 2a272f9a2..a2d98f824 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -253,7 +253,7 @@ func (a *ServingEndpointsAPI) GetPermissionsByServingEndpointId(ctx context.Cont // Retrieve all serving endpoints. // // This method is generated by Databricks SDK Code Generator. -func (a *ServingEndpointsAPI) List(ctx context.Context) (it listing.Iterator[ServingEndpoint]) { +func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListEndpointsResponse, ServingEndpoint] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListEndpointsResponse, error) { @@ -264,18 +264,20 @@ func (a *ServingEndpointsAPI) List(ctx context.Context) (it listing.Iterator[Ser return resp.Endpoints } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Retrieve all serving endpoints. +// +// This method is generated by Databricks SDK Code Generator. func (a *ServingEndpointsAPI) ListAll(ctx context.Context) ([]ServingEndpoint, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // Retrieve the most recent log lines associated with a given serving endpoint's diff --git a/service/settings/api.go b/service/settings/api.go index 8899c5e01..8a0581bd7 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -117,7 +117,7 @@ func (a *AccountIpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAcc // Gets all IP access lists for the specified account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountIpAccessListsAPI) List(ctx context.Context) (it listing.Iterator[IpAccessListInfo]) { +func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *GetIpAccessListsResponse, IpAccessListInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetIpAccessListsResponse, error) { @@ -128,18 +128,22 @@ func (a *AccountIpAccessListsAPI) List(ctx context.Context) (it listing.Iterator return resp.IpAccessLists } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get access lists. +// +// Gets all IP access lists for the specified account. +// +// This method is generated by Databricks SDK Code Generator. func (a *AccountIpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // IpAccessListInfoLabelToListIdMap calls [AccountIpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -430,7 +434,7 @@ func (a *IpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAccessList // Gets all IP access lists for the specified workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *IpAccessListsAPI) List(ctx context.Context) (it listing.Iterator[IpAccessListInfo]) { +func (a *IpAccessListsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListIpAccessListResponse, IpAccessListInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListIpAccessListResponse, error) { @@ -441,18 +445,22 @@ func (a *IpAccessListsAPI) List(ctx context.Context) (it listing.Iterator[IpAcce return resp.IpAccessLists } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get access lists. +// +// Gets all IP access lists for the specified workspace. +// +// This method is generated by Databricks SDK Code Generator. func (a *IpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // IpAccessListInfoLabelToListIdMap calls [IpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -689,7 +697,7 @@ func (a *TokenManagementAPI) GetPermissions(ctx context.Context) (*TokenPermissi // Lists all tokens associated with the specified workspace or user. // // This method is generated by Databricks SDK Code Generator. -func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManagementRequest) (it listing.Iterator[TokenInfo]) { +func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManagementRequest) *listing.IteratorImpl[ListTokenManagementRequest, *ListTokensResponse, TokenInfo] { getNextPage := func(ctx context.Context, req ListTokenManagementRequest) (*ListTokensResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -699,18 +707,22 @@ func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManageme return resp.TokenInfos } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List all tokens. +// +// Lists all tokens associated with the specified workspace or user. +// +// This method is generated by Databricks SDK Code Generator. func (a *TokenManagementAPI) ListAll(ctx context.Context, request ListTokenManagementRequest) ([]TokenInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // TokenInfoCommentToTokenIdMap calls [TokenManagementAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. @@ -847,7 +859,7 @@ func (a *TokensAPI) DeleteByTokenId(ctx context.Context, tokenId string) error { // Lists all the valid tokens for a user-workspace pair. // // This method is generated by Databricks SDK Code Generator. -func (a *TokensAPI) List(ctx context.Context) (it listing.Iterator[TokenInfo]) { +func (a *TokensAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListTokensResponse, TokenInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListTokensResponse, error) { @@ -858,18 +870,22 @@ func (a *TokensAPI) List(ctx context.Context) (it listing.Iterator[TokenInfo]) { return resp.TokenInfos } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List tokens. +// +// Lists all the valid tokens for a user-workspace pair. +// +// This method is generated by Databricks SDK Code Generator. func (a *TokensAPI) ListAll(ctx context.Context) ([]TokenInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // TokenInfoCommentToTokenIdMap calls [TokensAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. diff --git a/service/sharing/api.go b/service/sharing/api.go index 14ef665d7..b38239b05 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -96,7 +96,7 @@ func (a *CleanRoomsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Clea // a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) (it listing.Iterator[CleanRoomInfo]) { +func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) *listing.IteratorImpl[ListCleanRoomsRequest, *ListCleanRoomsResponse, CleanRoomInfo] { getNextPage := func(ctx context.Context, req ListCleanRoomsRequest) (*ListCleanRoomsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -112,32 +112,24 @@ func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List clean rooms. +// +// Gets an array of data object clean rooms from the metastore. The caller must +// be a metastore admin or the owner of the clean room. There is no guarantee of +// a specific ordering of the elements in the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsRequest) ([]CleanRoomInfo, error) { - iter := a.List(ctx, request) - var results []CleanRoomInfo - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.List(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -245,7 +237,7 @@ func (a *ProvidersAPI) GetByName(ctx context.Context, name string) (*ProviderInf // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) (it listing.Iterator[ProviderInfo]) { +func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) *listing.IteratorImpl[ListProvidersRequest, *ListProvidersResponse, ProviderInfo] { getNextPage := func(ctx context.Context, req ListProvidersRequest) (*ListProvidersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -255,18 +247,25 @@ func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) ( return resp.Providers } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List providers. +// +// Gets an array of available authentication providers. The caller must either +// be a metastore admin or the owner of the providers. Providers not owned by +// the caller are not included in the response. There is no guarantee of a +// specific ordering of the elements in the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // ProviderInfoNameToMetastoreIdMap calls [ProvidersAPI.ListAll] and creates a map of results with [ProviderInfo].Name as key and [ProviderInfo].MetastoreId as value. @@ -301,7 +300,7 @@ func (a *ProvidersAPI) ProviderInfoNameToMetastoreIdMap(ctx context.Context, req // * the caller is a metastore admin, or * the caller is the owner. // // This method is generated by Databricks SDK Code Generator. -func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest) (it listing.Iterator[ProviderShare]) { +func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest) *listing.IteratorImpl[ListSharesRequest, *ListProviderSharesResponse, ProviderShare] { getNextPage := func(ctx context.Context, req ListSharesRequest) (*ListProviderSharesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -311,18 +310,24 @@ func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest return resp.Shares } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List shares by Provider. +// +// Gets an array of a specified provider's shares within the metastore where: +// +// * the caller is a metastore admin, or * the caller is the owner. +// +// This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListSharesAll(ctx context.Context, request ListSharesRequest) ([]ProviderShare, error) { - iter := a.ListShares(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.ListShares(ctx, request) + return listing.ToSlice(ctx, iterator) } // List shares by Provider. @@ -514,7 +519,7 @@ func (a *RecipientsAPI) GetByName(ctx context.Context, name string) (*RecipientI // guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) (it listing.Iterator[RecipientInfo]) { +func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) *listing.IteratorImpl[ListRecipientsRequest, *ListRecipientsResponse, RecipientInfo] { getNextPage := func(ctx context.Context, req ListRecipientsRequest) (*ListRecipientsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -524,18 +529,25 @@ func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) return resp.Recipients } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List share recipients. +// +// Gets an array of all share recipients within the current metastore where: +// +// * the caller is a metastore admin, or * the caller is the owner. There is no +// guarantee of a specific ordering of the elements in the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *RecipientsAPI) ListAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // RecipientInfoNameToMetastoreIdMap calls [RecipientsAPI.ListAll] and creates a map of results with [RecipientInfo].Name as key and [RecipientInfo].MetastoreId as value. @@ -682,7 +694,7 @@ func (a *SharesAPI) GetByName(ctx context.Context, name string) (*ShareInfo, err // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *SharesAPI) List(ctx context.Context) (it listing.Iterator[ShareInfo]) { +func (a *SharesAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListSharesResponse, ShareInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListSharesResponse, error) { @@ -693,18 +705,24 @@ func (a *SharesAPI) List(ctx context.Context) (it listing.Iterator[ShareInfo]) { return resp.Shares } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List shares. +// +// Gets an array of data object shares from the metastore. The caller must be a +// metastore admin or the owner of the share. There is no guarantee of a +// specific ordering of the elements in the array. +// +// This method is generated by Databricks SDK Code Generator. func (a *SharesAPI) ListAll(ctx context.Context) ([]ShareInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // Get permissions. diff --git a/service/sql/api.go b/service/sql/api.go index 42c9f551f..bd6dd541d 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -286,7 +286,7 @@ func (a *DashboardsAPI) GetByDashboardId(ctx context.Context, dashboardId string // Fetch a paginated list of dashboard objects. // // This method is generated by Databricks SDK Code Generator. -func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) (it listing.Iterator[Dashboard]) { +func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) *listing.DedupeIteratorImpl[Dashboard, string] { request.Page = 1 // start iterating from the first page @@ -304,36 +304,27 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) request.Page = resp.Page + 1 return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - it = listing.NewDedupeIterator( - it, + dedupedIterator := listing.NewDedupeIterator( + iterator, func(item Dashboard) string { return item.Id }) - return it + return dedupedIterator } +// Get dashboard objects. +// +// Fetch a paginated list of dashboard objects. +// +// This method is generated by Databricks SDK Code Generator. func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { - iter := a.List(ctx, request) - var results []Dashboard - var totalCount int = 0 - limit := request.PageSize - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.List(ctx, request) + return listing.ToSliceN(ctx, iterator, request.PageSize) } @@ -658,7 +649,7 @@ func (a *QueriesAPI) GetByQueryId(ctx context.Context, queryId string) (*Query, // term. // // This method is generated by Databricks SDK Code Generator. -func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) (it listing.Iterator[Query]) { +func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *listing.DedupeIteratorImpl[Query, string] { request.Page = 1 // start iterating from the first page @@ -676,36 +667,28 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) (it l request.Page = resp.Page + 1 return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - it = listing.NewDedupeIterator( - it, + dedupedIterator := listing.NewDedupeIterator( + iterator, func(item Query) string { return item.Id }) - return it + return dedupedIterator } +// Get a list of queries. +// +// Gets a list of queries. Optionally, this list can be filtered by a search +// term. +// +// This method is generated by Databricks SDK Code Generator. func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { - iter := a.List(ctx, request) - var results []Query - var totalCount int = 0 - limit := request.PageSize - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.List(ctx, request) + return listing.ToSliceN(ctx, iterator, request.PageSize) } @@ -813,7 +796,7 @@ func (a *QueryHistoryAPI) Impl() QueryHistoryService { // You can filter by user ID, warehouse ID, status, and time range. // // This method is generated by Databricks SDK Code Generator. -func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequest) (it listing.Iterator[QueryInfo]) { +func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequest) *listing.IteratorImpl[ListQueryHistoryRequest, *ListQueriesResponse, QueryInfo] { getNextPage := func(ctx context.Context, req ListQueryHistoryRequest) (*ListQueriesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -829,32 +812,24 @@ func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequ request.PageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// List Queries. +// +// List the history of queries through SQL warehouses. +// +// You can filter by user ID, warehouse ID, status, and time range. +// +// This method is generated by Databricks SDK Code Generator. func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) { - iter := a.List(ctx, request) - var results []QueryInfo - var totalCount int = 0 - limit := request.MaxResults - for iter.HasNext(ctx) { - next, err := iter.Next(ctx) - if err != nil { - return nil, err - } - results = append(results, next) - totalCount++ - if limit > 0 && totalCount >= limit { - break - } - } - return results, nil + iterator := a.List(ctx, request) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -1424,7 +1399,7 @@ func (a *WarehousesAPI) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWo // Lists all SQL warehouses that a user has manager permissions on. // // This method is generated by Databricks SDK Code Generator. -func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) (it listing.Iterator[EndpointInfo]) { +func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) *listing.IteratorImpl[ListWarehousesRequest, *ListWarehousesResponse, EndpointInfo] { getNextPage := func(ctx context.Context, req ListWarehousesRequest) (*ListWarehousesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1434,18 +1409,22 @@ func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) return resp.Warehouses } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List warehouses. +// +// Lists all SQL warehouses that a user has manager permissions on. +// +// This method is generated by Databricks SDK Code Generator. func (a *WarehousesAPI) ListAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // EndpointInfoNameToIdMap calls [WarehousesAPI.ListAll] and creates a map of results with [EndpointInfo].Name as key and [EndpointInfo].Id as value. diff --git a/service/sql/model.go b/service/sql/model.go index 8e2fc3298..d4db5f8a3 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -280,6 +280,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/workspace/api.go b/service/workspace/api.go index 0bb649804..446141b99 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -92,7 +92,7 @@ func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId // supported. // // This method is generated by Databricks SDK Code Generator. -func (a *GitCredentialsAPI) List(ctx context.Context) (it listing.Iterator[CredentialInfo]) { +func (a *GitCredentialsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *GetCredentialsResponse, CredentialInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetCredentialsResponse, error) { @@ -103,18 +103,23 @@ func (a *GitCredentialsAPI) List(ctx context.Context) (it listing.Iterator[Crede return resp.Credentials } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Get Git credentials. +// +// Lists the calling user's Git credentials. One credential per user is +// supported. +// +// This method is generated by Databricks SDK Code Generator. func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error) { - iter := a.List(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx) + return listing.ToSlice(ctx, iterator) } // CredentialInfoGitProviderToCredentialIdMap calls [GitCredentialsAPI.ListAll] and creates a map of results with [CredentialInfo].GitProvider as key and [CredentialInfo].CredentialId as value. @@ -294,7 +299,7 @@ func (a *ReposAPI) GetPermissionsByRepoId(ctx context.Context, repoId string) (* // paginated with each page containing twenty repos. // // This method is generated by Databricks SDK Code Generator. -func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) (it listing.Iterator[RepoInfo]) { +func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing.IteratorImpl[ListReposRequest, *ListReposResponse, RepoInfo] { getNextPage := func(ctx context.Context, req ListReposRequest) (*ListReposResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -310,18 +315,23 @@ func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) (it listi request.NextPageToken = resp.NextPageToken return &request } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, getNextReq) - - return it + return iterator } +// Get repos. +// +// Returns repos that the calling user has Manage permissions on. Results are +// paginated with each page containing twenty repos. +// +// This method is generated by Databricks SDK Code Generator. func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // RepoInfoPathToIdMap calls [ReposAPI.ListAll] and creates a map of results with [RepoInfo].Path as key and [RepoInfo].Id as value. @@ -536,7 +546,7 @@ func (a *SecretsAPI) GetSecret(ctx context.Context, request GetSecretRequest) (* // call. // // This method is generated by Databricks SDK Code Generator. -func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) (it listing.Iterator[AclItem]) { +func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *listing.IteratorImpl[ListAclsRequest, *ListAclsResponse, AclItem] { getNextPage := func(ctx context.Context, req ListAclsRequest) (*ListAclsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -546,18 +556,27 @@ func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) (it return resp.Items } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// Lists ACLs. +// +// List the ACLs for a given secret scope. Users must have the `MANAGE` +// permission to invoke this API. +// +// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws +// `PERMISSION_DENIED` if the user does not have permission to make this API +// call. +// +// This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) { - iter := a.ListAcls(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.ListAcls(ctx, request) + return listing.ToSlice(ctx, iterator) } // Lists ACLs. @@ -582,7 +601,7 @@ func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAc // API call. // // This method is generated by Databricks SDK Code Generator. -func (a *SecretsAPI) ListScopes(ctx context.Context) (it listing.Iterator[SecretScope]) { +func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.IteratorImpl[struct{}, *ListScopesResponse, SecretScope] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListScopesResponse, error) { @@ -593,18 +612,25 @@ func (a *SecretsAPI) ListScopes(ctx context.Context) (it listing.Iterator[Secret return resp.Scopes } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List all scopes. +// +// Lists all secret scopes available in the workspace. +// +// Throws `PERMISSION_DENIED` if the user does not have permission to make this +// API call. +// +// This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { - iter := a.ListScopes(ctx) - return listing.ToSlice(ctx, iter) + iterator := a.ListScopes(ctx) + return listing.ToSlice(ctx, iterator) } // List secret keys. @@ -619,7 +645,7 @@ func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { // call. // // This method is generated by Databricks SDK Code Generator. -func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) (it listing.Iterator[SecretMetadata]) { +func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) *listing.IteratorImpl[ListSecretsRequest, *ListSecretsResponse, SecretMetadata] { getNextPage := func(ctx context.Context, req ListSecretsRequest) (*ListSecretsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -629,18 +655,29 @@ func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest return resp.Secrets } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List secret keys. +// +// Lists the secret keys that are stored at this scope. This is a metadata-only +// operation; secret data cannot be retrieved using this API. Users need the +// READ permission to make this call. +// +// The lastUpdatedTimestamp returned is in milliseconds since epoch. Throws +// `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws +// `PERMISSION_DENIED` if the user does not have permission to make this API +// call. +// +// This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) { - iter := a.ListSecrets(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.ListSecrets(ctx, request) + return listing.ToSlice(ctx, iterator) } // List secret keys. @@ -848,7 +885,7 @@ func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error { // `RESOURCE_DOES_NOT_EXIST`. // // This method is generated by Databricks SDK Code Generator. -func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) (it listing.Iterator[ObjectInfo]) { +func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) *listing.IteratorImpl[ListWorkspaceRequest, *ListResponse, ObjectInfo] { getNextPage := func(ctx context.Context, req ListWorkspaceRequest) (*ListResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -858,18 +895,24 @@ func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) ( return resp.Objects } - it = listing.NewIterator( + iterator := listing.NewIterator( &request, getNextPage, getItems, nil) - - return it + return iterator } +// List contents. +// +// Lists the contents of a directory, or the object if it is not a directory. If +// the input path does not exist, this call returns an error +// `RESOURCE_DOES_NOT_EXIST`. +// +// This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error) { - iter := a.List(ctx, request) - return listing.ToSlice(ctx, iter) + iterator := a.List(ctx, request) + return listing.ToSlice(ctx, iterator) } // ObjectInfoPathToObjectIdMap calls [WorkspaceAPI.ListAll] and creates a map of results with [ObjectInfo].Path as key and [ObjectInfo].ObjectId as value. From 206f568000807e7d5b52050dcce54f7249360581 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Mon, 23 Oct 2023 09:44:40 +0200 Subject: [PATCH 21/24] Last feedback --- .codegen/api.go.tmpl | 6 ++--- listing/listing.go | 26 ++++++++++----------- service/billing/api.go | 4 ++-- service/catalog/api.go | 30 ++++++++++++------------- service/compute/api.go | 16 ++++++------- service/files/api.go | 2 +- service/iam/api.go | 14 ++++++------ service/iam/model.go | 4 ++-- service/jobs/api.go | 4 ++-- service/ml/api.go | 22 +++++++++--------- service/ml/model_registry_usage_test.go | 26 ++++++++++----------- service/oauth2/api.go | 8 +++---- service/pipelines/api.go | 4 ++-- service/serving/api.go | 2 +- service/settings/api.go | 8 +++---- service/sharing/api.go | 10 ++++----- service/sql/api.go | 12 +++++----- service/sql/model.go | 1 - service/workspace/api.go | 12 +++++----- 19 files changed, 105 insertions(+), 106 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 06c939696..444166d5f 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -205,7 +205,7 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} getItems, {{if .Pagination.MultiRequest}}getNextReq{{else}}nil{{end}}) {{ if .NeedsOffsetDedupe -}} - dedupedIterator := listing.NewDedupeIterator( + dedupedIterator := listing.NewDedupeIterator[{{ template "type" .Pagination.Entity }}, {{ template "type" .IdentifierField.Entity }}]( iterator, func(item {{ template "type" .Pagination.Entity }}) {{ template "type" .IdentifierField.Entity }} { return item{{ template "field-path" .IdFieldPath }} @@ -307,8 +307,8 @@ func (a *{{.Service.Name}}API) {{.Shortcut.PascalName}}AndWait(ctx context.Conte {{- end -}} {{- define "paginated-return-type" -}} {{ if .NeedsOffsetDedupe -}} - *listing.DedupeIteratorImpl[{{ template "type" .Pagination.Entity }}, {{ template "type" .IdentifierField.Entity }}] + *listing.DeduplicatingIterator[{{ template "type" .Pagination.Entity }}, {{ template "type" .IdentifierField.Entity }}] {{- else -}} - *listing.IteratorImpl[{{ template "paginated-request-type" .}}, *{{ .Response.PascalName }}, {{ template "type" .Pagination.Entity }}] + *listing.PaginatingIterator[{{ template "paginated-request-type" .}}, *{{ .Response.PascalName }}, {{ template "type" .Pagination.Entity }}] {{- end -}} {{- end -}} \ No newline at end of file diff --git a/listing/listing.go b/listing/listing.go index 05e30c2a5..aa2ab97ee 100644 --- a/listing/listing.go +++ b/listing/listing.go @@ -52,7 +52,7 @@ func ToSliceN[T any, Limit ~int | ~int64](ctx context.Context, it Iterator[T], n } // Use struct{} for Req for iterators that don't need any request structure. -type IteratorImpl[Req, Resp, T any] struct { +type PaginatingIterator[Req, Resp, T any] struct { // nextReq is the request to be used to fetch the next page. If nil, then // there is no next page to fetch. nextReq *Req @@ -92,8 +92,8 @@ func NewIterator[Req, Resp, T any]( getNextPage func(context.Context, Req) (Resp, error), getItems func(Resp) []T, getNextReq func(Resp) *Req, -) *IteratorImpl[Req, Resp, T] { - return &IteratorImpl[Req, Resp, T]{ +) *PaginatingIterator[Req, Resp, T] { + return &PaginatingIterator[Req, Resp, T]{ nextReq: nextReq, getNextPage: getNextPage, getItems: getItems, @@ -101,7 +101,7 @@ func NewIterator[Req, Resp, T any]( } } -func (i *IteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error { +func (i *PaginatingIterator[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) error { if i.currentPageIdx < len(i.currentPage) { return nil } @@ -133,7 +133,7 @@ func (i *IteratorImpl[Req, Resp, T]) loadNextPageIfNeeded(ctx context.Context) e return nil } -func (i *IteratorImpl[Req, Resp, T]) Next(ctx context.Context) (T, error) { +func (i *PaginatingIterator[Req, Resp, T]) Next(ctx context.Context) (T, error) { var t T err := i.loadNextPageIfNeeded(ctx) if err != nil { @@ -147,7 +147,7 @@ func (i *IteratorImpl[Req, Resp, T]) Next(ctx context.Context) (T, error) { return item, nil } -func (i *IteratorImpl[Req, Resp, T]) HasNext(ctx context.Context) bool { +func (i *PaginatingIterator[Req, Resp, T]) HasNext(ctx context.Context) bool { err := i.loadNextPageIfNeeded(ctx) // As described in the documentation for HasNext, if there was an error // fetching the next page, we still return true to allow the user to handle @@ -158,22 +158,22 @@ func (i *IteratorImpl[Req, Resp, T]) HasNext(ctx context.Context) bool { return i.currentPageIdx < len(i.currentPage) } -type DedupeIteratorImpl[T any, Id comparable] struct { +type DeduplicatingIterator[T any, Id comparable] struct { it Iterator[T] getId func(T) Id seen map[Id]struct{} current *T } -func NewDedupeIterator[T any, Id comparable](it Iterator[T], getId func(T) Id) *DedupeIteratorImpl[T, Id] { - return &DedupeIteratorImpl[T, Id]{ +func NewDedupeIterator[T any, Id comparable](it Iterator[T], getId func(T) Id) *DeduplicatingIterator[T, Id] { + return &DeduplicatingIterator[T, Id]{ it: it, getId: getId, seen: make(map[Id]struct{}), } } -func (i *DedupeIteratorImpl[T, Id]) Next(ctx context.Context) (T, error) { +func (i *DeduplicatingIterator[T, Id]) Next(ctx context.Context) (T, error) { if i.current != nil { t := *i.current i.current = nil @@ -192,12 +192,12 @@ func (i *DedupeIteratorImpl[T, Id]) Next(ctx context.Context) (T, error) { } } -func (i *DedupeIteratorImpl[T, Id]) HasNext(ctx context.Context) bool { +func (i *DeduplicatingIterator[T, Id]) HasNext(ctx context.Context) bool { if i.current != nil { return true } - // To compute HasNext in dedupeIteratorImpl, we need to actually fetch the - // next item from the underlying iterator and compare it to seen items. + // To compute HasNext in DeduplicatingIterator, we need to actually fetch + // the next item from the underlying iterator and compare it to seen items. // However, the retrieved item cannot be discarded, as it needs to be // returned by the next call to Next. So we store the item in current and // return it in the next call to Next, after which current is set to nil. diff --git a/service/billing/api.go b/service/billing/api.go index e6361bd47..3d06edd36 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -131,7 +131,7 @@ func (a *BudgetsAPI) GetByBudgetId(ctx context.Context, budgetId string) (*Wrapp // for each day that the budget is configured to include. // // This method is generated by Databricks SDK Code Generator. -func (a *BudgetsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *BudgetList, BudgetWithStatus] { +func (a *BudgetsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *BudgetList, BudgetWithStatus] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*BudgetList, error) { @@ -364,7 +364,7 @@ func (a *LogDeliveryAPI) GetByLogDeliveryConfigurationId(ctx context.Context, lo // specified by ID. // // This method is generated by Databricks SDK Code Generator. -func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryRequest) *listing.IteratorImpl[ListLogDeliveryRequest, *WrappedLogDeliveryConfigurations, LogDeliveryConfiguration] { +func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryRequest) *listing.PaginatingIterator[ListLogDeliveryRequest, *WrappedLogDeliveryConfigurations, LogDeliveryConfiguration] { getNextPage := func(ctx context.Context, req ListLogDeliveryRequest) (*WrappedLogDeliveryConfigurations, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") diff --git a/service/catalog/api.go b/service/catalog/api.go index 49b988cfa..a9874b661 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -93,7 +93,7 @@ func (a *AccountMetastoreAssignmentsAPI) GetByWorkspaceId(ctx context.Context, w // metastore. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) *listing.IteratorImpl[ListAccountMetastoreAssignmentsRequest, *ListAccountMetastoreAssignmentsResponse, int64] { +func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) *listing.PaginatingIterator[ListAccountMetastoreAssignmentsRequest, *ListAccountMetastoreAssignmentsResponse, int64] { getNextPage := func(ctx context.Context, req ListAccountMetastoreAssignmentsRequest) (*ListAccountMetastoreAssignmentsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -212,7 +212,7 @@ func (a *AccountMetastoresAPI) GetByMetastoreId(ctx context.Context, metastoreId // Gets all Unity Catalog metastores associated with an account specified by ID. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListMetastoresResponse, MetastoreInfo] { +func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListMetastoresResponse, MetastoreInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { @@ -554,7 +554,7 @@ func (a *CatalogsAPI) GetByName(ctx context.Context, name string) (*CatalogInfo, // the array. // // This method is generated by Databricks SDK Code Generator. -func (a *CatalogsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListCatalogsResponse, CatalogInfo] { +func (a *CatalogsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListCatalogsResponse, CatalogInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListCatalogsResponse, error) { @@ -681,7 +681,7 @@ func (a *ConnectionsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Con // List all connections. // // This method is generated by Databricks SDK Code Generator. -func (a *ConnectionsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListConnectionsResponse, ConnectionInfo] { +func (a *ConnectionsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListConnectionsResponse, ConnectionInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListConnectionsResponse, error) { @@ -865,7 +865,7 @@ func (a *ExternalLocationsAPI) GetByName(ctx context.Context, name string) (*Ext // array. // // This method is generated by Databricks SDK Code Generator. -func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListExternalLocationsResponse, ExternalLocationInfo] { +func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListExternalLocationsResponse, ExternalLocationInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListExternalLocationsResponse, error) { @@ -1017,7 +1017,7 @@ func (a *FunctionsAPI) GetByName(ctx context.Context, name string) (*FunctionInf // the array. // // This method is generated by Databricks SDK Code Generator. -func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) *listing.IteratorImpl[ListFunctionsRequest, *ListFunctionsResponse, FunctionInfo] { +func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) *listing.PaginatingIterator[ListFunctionsRequest, *ListFunctionsResponse, FunctionInfo] { getNextPage := func(ctx context.Context, req ListFunctionsRequest) (*ListFunctionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1279,7 +1279,7 @@ func (a *MetastoresAPI) GetById(ctx context.Context, id string) (*MetastoreInfo, // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *MetastoresAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListMetastoresResponse, MetastoreInfo] { +func (a *MetastoresAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListMetastoresResponse, MetastoreInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListMetastoresResponse, error) { @@ -1538,7 +1538,7 @@ func (a *ModelVersionsAPI) GetByAliasByFullNameAndAlias(ctx context.Context, ful // There is no guarantee of a specific ordering of the elements in the response. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRequest) *listing.IteratorImpl[ListModelVersionsRequest, *ListModelVersionsResponse, ModelVersionInfo] { +func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRequest) *listing.PaginatingIterator[ListModelVersionsRequest, *ListModelVersionsResponse, ModelVersionInfo] { getNextPage := func(ctx context.Context, req ListModelVersionsRequest) (*ListModelVersionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1788,7 +1788,7 @@ func (a *RegisteredModelsAPI) GetByFullName(ctx context.Context, fullName string // There is no guarantee of a specific ordering of the elements in the response. // // This method is generated by Databricks SDK Code Generator. -func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) *listing.IteratorImpl[ListRegisteredModelsRequest, *ListRegisteredModelsResponse, RegisteredModelInfo] { +func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredModelsRequest) *listing.PaginatingIterator[ListRegisteredModelsRequest, *ListRegisteredModelsResponse, RegisteredModelInfo] { getNextPage := func(ctx context.Context, req ListRegisteredModelsRequest) (*ListRegisteredModelsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2001,7 +2001,7 @@ func (a *SchemasAPI) GetByFullName(ctx context.Context, fullName string) (*Schem // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *listing.IteratorImpl[ListSchemasRequest, *ListSchemasResponse, SchemaInfo] { +func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *listing.PaginatingIterator[ListSchemasRequest, *ListSchemasResponse, SchemaInfo] { getNextPage := func(ctx context.Context, req ListSchemasRequest) (*ListSchemasResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2190,7 +2190,7 @@ func (a *StorageCredentialsAPI) GetByName(ctx context.Context, name string) (*St // of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListStorageCredentialsResponse, StorageCredentialInfo] { +func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListStorageCredentialsResponse, StorageCredentialInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListStorageCredentialsResponse, error) { @@ -2335,7 +2335,7 @@ func (a *SystemSchemasAPI) Enable(ctx context.Context, request EnableRequest) er // account admin or a metastore admin. // // This method is generated by Databricks SDK Code Generator. -func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRequest) *listing.IteratorImpl[ListSystemSchemasRequest, *ListSystemSchemasResponse, SystemSchemaInfo] { +func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRequest) *listing.PaginatingIterator[ListSystemSchemasRequest, *ListSystemSchemasResponse, SystemSchemaInfo] { getNextPage := func(ctx context.Context, req ListSystemSchemasRequest) (*ListSystemSchemasResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2555,7 +2555,7 @@ func (a *TablesAPI) GetByFullName(ctx context.Context, fullName string) (*TableI // guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listing.IteratorImpl[ListTablesRequest, *ListTablesResponse, TableInfo] { +func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listing.PaginatingIterator[ListTablesRequest, *ListTablesResponse, TableInfo] { getNextPage := func(ctx context.Context, req ListTablesRequest) (*ListTablesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2663,7 +2663,7 @@ func (a *TablesAPI) GetByName(ctx context.Context, name string) (*TableInfo, err // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequest) *listing.IteratorImpl[ListSummariesRequest, *ListTableSummariesResponse, TableSummary] { +func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequest) *listing.PaginatingIterator[ListSummariesRequest, *ListTableSummariesResponse, TableSummary] { getNextPage := func(ctx context.Context, req ListSummariesRequest) (*ListTableSummariesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2818,7 +2818,7 @@ func (a *VolumesAPI) DeleteByFullNameArg(ctx context.Context, fullNameArg string // There is no guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *listing.IteratorImpl[ListVolumesRequest, *ListVolumesResponseContent, VolumeInfo] { +func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *listing.PaginatingIterator[ListVolumesRequest, *ListVolumesResponseContent, VolumeInfo] { getNextPage := func(ctx context.Context, req ListVolumesRequest) (*ListVolumesResponseContent, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") diff --git a/service/compute/api.go b/service/compute/api.go index 315e4ed91..5bb52a5d2 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -154,7 +154,7 @@ func (a *ClusterPoliciesAPI) GetPermissionsByClusterPolicyId(ctx context.Context // Returns a list of policies accessible by the requesting user. // // This method is generated by Databricks SDK Code Generator. -func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPoliciesRequest) *listing.IteratorImpl[ListClusterPoliciesRequest, *ListPoliciesResponse, Policy] { +func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPoliciesRequest) *listing.PaginatingIterator[ListClusterPoliciesRequest, *ListPoliciesResponse, Policy] { getNextPage := func(ctx context.Context, req ListClusterPoliciesRequest) (*ListPoliciesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -604,7 +604,7 @@ func (a *ClustersAPI) EditAndWait(ctx context.Context, editCluster EditCluster, // nparameters necessary to request the next page of events. // // This method is generated by Databricks SDK Code Generator. -func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.IteratorImpl[GetEvents, *GetEventsResponse, ClusterEvent] { +func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.PaginatingIterator[GetEvents, *GetEventsResponse, ClusterEvent] { getNextPage := func(ctx context.Context, req GetEvents) (*GetEventsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -707,7 +707,7 @@ func (a *ClustersAPI) GetPermissionsByClusterId(ctx context.Context, clusterId s // terminated job clusters. // // This method is generated by Databricks SDK Code Generator. -func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *listing.IteratorImpl[ListClustersRequest, *ListClustersResponse, ClusterDetails] { +func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *listing.PaginatingIterator[ListClustersRequest, *ListClustersResponse, ClusterDetails] { getNextPage := func(ctx context.Context, req ListClustersRequest) (*ListClustersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1549,7 +1549,7 @@ func (a *GlobalInitScriptsAPI) GetByScriptId(ctx context.Context, scriptId strin // script](#operation/get-script) operation. // // This method is generated by Databricks SDK Code Generator. -func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListGlobalInitScriptsResponse, GlobalInitScriptDetails] { +func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListGlobalInitScriptsResponse, GlobalInitScriptDetails] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListGlobalInitScriptsResponse, error) { @@ -1773,7 +1773,7 @@ func (a *InstancePoolsAPI) GetPermissionsByInstancePoolId(ctx context.Context, i // Gets a list of instance pools with their statistics. // // This method is generated by Databricks SDK Code Generator. -func (a *InstancePoolsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListInstancePools, InstancePoolAndStats] { +func (a *InstancePoolsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListInstancePools, InstancePoolAndStats] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListInstancePools, error) { @@ -1939,7 +1939,7 @@ func (a *InstanceProfilesAPI) Edit(ctx context.Context, request InstanceProfile) // This API is available to all users. // // This method is generated by Databricks SDK Code Generator. -func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListInstanceProfilesResponse, InstanceProfile] { +func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListInstanceProfilesResponse, InstanceProfile] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListInstanceProfilesResponse, error) { @@ -2067,7 +2067,7 @@ func (a *LibrariesAPI) AllClusterStatuses(ctx context.Context) (*ListAllClusterL // guarantee. // // This method is generated by Databricks SDK Code Generator. -func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) *listing.IteratorImpl[ClusterStatusRequest, *ClusterLibraryStatuses, LibraryFullStatus] { +func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusRequest) *listing.PaginatingIterator[ClusterStatusRequest, *ClusterLibraryStatuses, LibraryFullStatus] { getNextPage := func(ctx context.Context, req ClusterStatusRequest) (*ClusterLibraryStatuses, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -2209,7 +2209,7 @@ func (a *PolicyFamiliesAPI) GetByPolicyFamilyId(ctx context.Context, policyFamil // Retrieve a list of policy families. This API is paginated. // // This method is generated by Databricks SDK Code Generator. -func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamiliesRequest) *listing.IteratorImpl[ListPolicyFamiliesRequest, *ListPolicyFamiliesResponse, PolicyFamily] { +func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamiliesRequest) *listing.PaginatingIterator[ListPolicyFamiliesRequest, *ListPolicyFamiliesResponse, PolicyFamily] { getNextPage := func(ctx context.Context, req ListPolicyFamiliesRequest) (*ListPolicyFamiliesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") diff --git a/service/files/api.go b/service/files/api.go index 60f61945a..0e394761b 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -142,7 +142,7 @@ func (a *DbfsAPI) GetStatusByPath(ctx context.Context, path string) (*FileInfo, // which provides the same functionality without timing out. // // This method is generated by Databricks SDK Code Generator. -func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.IteratorImpl[ListDbfsRequest, *ListStatusResponse, FileInfo] { +func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.PaginatingIterator[ListDbfsRequest, *ListStatusResponse, FileInfo] { getNextPage := func(ctx context.Context, req ListDbfsRequest) (*ListStatusResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") diff --git a/service/iam/api.go b/service/iam/api.go index 30e9503d7..4fdf5379e 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -203,7 +203,7 @@ func (a *AccountGroupsAPI) GetById(ctx context.Context, id string) (*Group, erro // Gets all details of the groups associated with the Databricks account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRequest) *listing.IteratorImpl[ListAccountGroupsRequest, *ListGroupsResponse, Group] { +func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRequest) *listing.PaginatingIterator[ListAccountGroupsRequest, *ListGroupsResponse, Group] { getNextPage := func(ctx context.Context, req ListAccountGroupsRequest) (*ListGroupsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -376,7 +376,7 @@ func (a *AccountServicePrincipalsAPI) GetById(ctx context.Context, id string) (* // Gets the set of service principals associated with a Databricks account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAccountServicePrincipalsRequest) *listing.IteratorImpl[ListAccountServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { +func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAccountServicePrincipalsRequest) *listing.PaginatingIterator[ListAccountServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { getNextPage := func(ctx context.Context, req ListAccountServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -558,7 +558,7 @@ func (a *AccountUsersAPI) GetById(ctx context.Context, id string) (*User, error) // Gets details for all the users associated with a Databricks account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequest) *listing.IteratorImpl[ListAccountUsersRequest, *ListUsersResponse, User] { +func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequest) *listing.PaginatingIterator[ListAccountUsersRequest, *ListUsersResponse, User] { getNextPage := func(ctx context.Context, req ListAccountUsersRequest) (*ListUsersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -767,7 +767,7 @@ func (a *GroupsAPI) GetById(ctx context.Context, id string) (*Group, error) { // Gets all details of the groups associated with the Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listing.IteratorImpl[ListGroupsRequest, *ListGroupsResponse, Group] { +func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listing.PaginatingIterator[ListGroupsRequest, *ListGroupsResponse, Group] { getNextPage := func(ctx context.Context, req ListGroupsRequest) (*ListGroupsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1065,7 +1065,7 @@ func (a *ServicePrincipalsAPI) GetById(ctx context.Context, id string) (*Service // Gets the set of service principals associated with a Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrincipalsRequest) *listing.IteratorImpl[ListServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { +func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrincipalsRequest) *listing.PaginatingIterator[ListServicePrincipalsRequest, *ListServicePrincipalResponse, ServicePrincipal] { getNextPage := func(ctx context.Context, req ListServicePrincipalsRequest) (*ListServicePrincipalResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1262,7 +1262,7 @@ func (a *UsersAPI) GetPermissions(ctx context.Context) (*PasswordPermissions, er // Gets details for all the users associated with a Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing.IteratorImpl[ListUsersRequest, *ListUsersResponse, User] { +func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing.PaginatingIterator[ListUsersRequest, *ListUsersResponse, User] { getNextPage := func(ctx context.Context, req ListUsersRequest) (*ListUsersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1445,7 +1445,7 @@ func (a *WorkspaceAssignmentAPI) GetByWorkspaceId(ctx context.Context, workspace // Databricks workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspaceAssignmentRequest) *listing.IteratorImpl[ListWorkspaceAssignmentRequest, *PermissionAssignments, PermissionAssignment] { +func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspaceAssignmentRequest) *listing.PaginatingIterator[ListWorkspaceAssignmentRequest, *PermissionAssignments, PermissionAssignment] { getNextPage := func(ctx context.Context, req ListWorkspaceAssignmentRequest) (*PermissionAssignments, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") diff --git a/service/iam/model.go b/service/iam/model.go index 8a1ba4cd1..4d1a0f3d0 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,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. @@ -1024,7 +1024,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty" url:"-"` + Id string `json:"id,omitempty"` Roles []ComplexValue `json:"roles,omitempty"` diff --git a/service/jobs/api.go b/service/jobs/api.go index 4feab9bb3..a2a1046ab 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -328,7 +328,7 @@ func (a *JobsAPI) GetRunOutputByRunId(ctx context.Context, runId int64) (*RunOut // Retrieves a list of jobs. // // This method is generated by Databricks SDK Code Generator. -func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.IteratorImpl[ListJobsRequest, *ListJobsResponse, BaseJob] { +func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.PaginatingIterator[ListJobsRequest, *ListJobsResponse, BaseJob] { getNextPage := func(ctx context.Context, req ListJobsRequest) (*ListJobsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -421,7 +421,7 @@ func (a *JobsAPI) GetBySettingsName(ctx context.Context, name string) (*BaseJob, // List runs in descending order by start time. // // This method is generated by Databricks SDK Code Generator. -func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listing.IteratorImpl[ListRunsRequest, *ListRunsResponse, BaseRun] { +func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listing.PaginatingIterator[ListRunsRequest, *ListRunsResponse, BaseRun] { getNextPage := func(ctx context.Context, req ListRunsRequest) (*ListRunsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") diff --git a/service/ml/api.go b/service/ml/api.go index 34fb9a9f9..71fd67333 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -127,7 +127,7 @@ func (a *ExperimentsAPI) GetExperiment(ctx context.Context, request GetExperimen // Gets a list of all values for the specified metric for a given run. // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) *listing.IteratorImpl[GetHistoryRequest, *GetMetricHistoryResponse, Metric] { +func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryRequest) *listing.PaginatingIterator[GetHistoryRequest, *GetMetricHistoryResponse, Metric] { getNextPage := func(ctx context.Context, req GetHistoryRequest) (*GetMetricHistoryResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -214,7 +214,7 @@ func (a *ExperimentsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Ge // specified, the response contains only artifacts with the specified prefix.", // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifactsRequest) *listing.IteratorImpl[ListArtifactsRequest, *ListArtifactsResponse, FileInfo] { +func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifactsRequest) *listing.PaginatingIterator[ListArtifactsRequest, *ListArtifactsResponse, FileInfo] { getNextPage := func(ctx context.Context, req ListArtifactsRequest) (*ListArtifactsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -254,7 +254,7 @@ func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtif // Gets a list of all experiments. // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperimentsRequest) *listing.IteratorImpl[ListExperimentsRequest, *ListExperimentsResponse, Experiment] { +func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperimentsRequest) *listing.PaginatingIterator[ListExperimentsRequest, *ListExperimentsResponse, Experiment] { getNextPage := func(ctx context.Context, req ListExperimentsRequest) (*ListExperimentsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -399,7 +399,7 @@ func (a *ExperimentsAPI) RestoreRuns(ctx context.Context, request RestoreRuns) ( // Searches for experiments that satisfy specified search criteria. // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchExperiments) *listing.IteratorImpl[SearchExperiments, *SearchExperimentsResponse, Experiment] { +func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchExperiments) *listing.PaginatingIterator[SearchExperiments, *SearchExperimentsResponse, Experiment] { getNextPage := func(ctx context.Context, req SearchExperiments) (*SearchExperimentsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -440,7 +440,7 @@ func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request Searc // Search expressions can use `mlflowMetric` and `mlflowParam` keys.", // // This method is generated by Databricks SDK Code Generator. -func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *listing.IteratorImpl[SearchRuns, *SearchRunsResponse, Run] { +func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *listing.PaginatingIterator[SearchRuns, *SearchRunsResponse, Run] { getNextPage := func(ctx context.Context, req SearchRuns) (*SearchRunsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -655,7 +655,7 @@ func (a *ModelRegistryAPI) DeleteWebhook(ctx context.Context, request DeleteWebh // Gets the latest version of a registered model. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) *listing.IteratorImpl[GetLatestVersionsRequest, *GetLatestVersionsResponse, ModelVersion] { +func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLatestVersionsRequest) *listing.PaginatingIterator[GetLatestVersionsRequest, *GetLatestVersionsResponse, ModelVersion] { getNextPage := func(ctx context.Context, req GetLatestVersionsRequest) (*GetLatestVersionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -748,7 +748,7 @@ func (a *ModelRegistryAPI) GetPermissionsByRegisteredModelId(ctx context.Context // __max_results__. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsRequest) *listing.IteratorImpl[ListModelsRequest, *ListModelsResponse, Model] { +func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsRequest) *listing.PaginatingIterator[ListModelsRequest, *ListModelsResponse, Model] { getNextPage := func(ctx context.Context, req ListModelsRequest) (*ListModelsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -789,7 +789,7 @@ func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModels // Gets a list of all open stage transition requests for the model version. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request ListTransitionRequestsRequest) *listing.IteratorImpl[ListTransitionRequestsRequest, *ListTransitionRequestsResponse, Activity] { +func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request ListTransitionRequestsRequest) *listing.PaginatingIterator[ListTransitionRequestsRequest, *ListTransitionRequestsResponse, Activity] { getNextPage := func(ctx context.Context, req ListTransitionRequestsRequest) (*ListTransitionRequestsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -824,7 +824,7 @@ func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, reques // Lists all registry webhooks. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhooksRequest) *listing.IteratorImpl[ListWebhooksRequest, *ListRegistryWebhooks, RegistryWebhook] { +func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhooksRequest) *listing.PaginatingIterator[ListWebhooksRequest, *ListRegistryWebhooks, RegistryWebhook] { getNextPage := func(ctx context.Context, req ListWebhooksRequest) (*ListRegistryWebhooks, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -879,7 +879,7 @@ func (a *ModelRegistryAPI) RenameModel(ctx context.Context, request RenameModelR // Searches for specific model versions based on the supplied __filter__. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request SearchModelVersionsRequest) *listing.IteratorImpl[SearchModelVersionsRequest, *SearchModelVersionsResponse, ModelVersion] { +func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request SearchModelVersionsRequest) *listing.PaginatingIterator[SearchModelVersionsRequest, *SearchModelVersionsResponse, ModelVersion] { getNextPage := func(ctx context.Context, req SearchModelVersionsRequest) (*SearchModelVersionsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -919,7 +919,7 @@ func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request S // Search for registered models based on the specified __filter__. // // This method is generated by Databricks SDK Code Generator. -func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModelsRequest) *listing.IteratorImpl[SearchModelsRequest, *SearchModelsResponse, Model] { +func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModelsRequest) *listing.PaginatingIterator[SearchModelsRequest, *SearchModelsResponse, Model] { getNextPage := func(ctx context.Context, req SearchModelsRequest) (*SearchModelsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index b5ccf9028..ff3c69793 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -58,24 +58,24 @@ func ExampleModelRegistryAPI_CreateComment_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_models() { +func ExampleModelRegistryAPI_CreateModel_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", model) } -func ExampleModelRegistryAPI_CreateModel_modelVersions() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -92,24 +92,24 @@ func ExampleModelRegistryAPI_CreateModel_modelVersions() { } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_models() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", model) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -124,18 +124,18 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { } logger.Infof(ctx, "found %v", model) - mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", mv) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -150,14 +150,14 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { } logger.Infof(ctx, "found %v", model) - created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", mv) } diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 1f1a38add..0e9a0e8ba 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -90,7 +90,7 @@ func (a *CustomAppIntegrationAPI) GetByIntegrationId(ctx context.Context, integr // account // // This method is generated by Databricks SDK Code Generator. -func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *GetCustomAppIntegrationsOutput, GetCustomAppIntegrationOutput] { +func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *GetCustomAppIntegrationsOutput, GetCustomAppIntegrationOutput] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetCustomAppIntegrationsOutput, error) { @@ -219,7 +219,7 @@ func (a *OAuthPublishedAppsAPI) Impl() OAuthPublishedAppsService { // Get all the available published OAuth apps in Databricks. // // This method is generated by Databricks SDK Code Generator. -func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPublishedAppsRequest) *listing.IteratorImpl[ListOAuthPublishedAppsRequest, *GetPublishedAppsOutput, PublishedAppOutput] { +func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPublishedAppsRequest) *listing.PaginatingIterator[ListOAuthPublishedAppsRequest, *GetPublishedAppsOutput, PublishedAppOutput] { getNextPage := func(ctx context.Context, req ListOAuthPublishedAppsRequest) (*GetPublishedAppsOutput, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -333,7 +333,7 @@ func (a *PublishedAppIntegrationAPI) GetByIntegrationId(ctx context.Context, int // account // // This method is generated by Databricks SDK Code Generator. -func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *GetPublishedAppIntegrationsOutput, GetPublishedAppIntegrationOutput] { +func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *GetPublishedAppIntegrationsOutput, GetPublishedAppIntegrationOutput] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetPublishedAppIntegrationsOutput, error) { @@ -441,7 +441,7 @@ func (a *ServicePrincipalSecretsAPI) DeleteByServicePrincipalIdAndSecretId(ctx c // the secret values. // // This method is generated by Databricks SDK Code Generator. -func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServicePrincipalSecretsRequest) *listing.IteratorImpl[ListServicePrincipalSecretsRequest, *ListServicePrincipalSecretsResponse, SecretInfo] { +func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServicePrincipalSecretsRequest) *listing.PaginatingIterator[ListServicePrincipalSecretsRequest, *ListServicePrincipalSecretsResponse, SecretInfo] { getNextPage := func(ctx context.Context, req ListServicePrincipalSecretsRequest) (*ListServicePrincipalSecretsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 8362253f5..1162d81c4 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -254,7 +254,7 @@ func (a *PipelinesAPI) GetUpdateByPipelineIdAndUpdateId(ctx context.Context, pip // Retrieves events for a pipeline. // // This method is generated by Databricks SDK Code Generator. -func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipelineEventsRequest) *listing.IteratorImpl[ListPipelineEventsRequest, *ListPipelineEventsResponse, PipelineEvent] { +func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipelineEventsRequest) *listing.PaginatingIterator[ListPipelineEventsRequest, *ListPipelineEventsResponse, PipelineEvent] { getNextPage := func(ctx context.Context, req ListPipelineEventsRequest) (*ListPipelineEventsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -303,7 +303,7 @@ func (a *PipelinesAPI) ListPipelineEventsByPipelineId(ctx context.Context, pipel // Lists pipelines defined in the Delta Live Tables system. // // This method is generated by Databricks SDK Code Generator. -func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesRequest) *listing.IteratorImpl[ListPipelinesRequest, *ListPipelinesResponse, PipelineStateInfo] { +func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesRequest) *listing.PaginatingIterator[ListPipelinesRequest, *ListPipelinesResponse, PipelineStateInfo] { getNextPage := func(ctx context.Context, req ListPipelinesRequest) (*ListPipelinesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") diff --git a/service/serving/api.go b/service/serving/api.go index a2d98f824..05d3ba9d6 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -253,7 +253,7 @@ func (a *ServingEndpointsAPI) GetPermissionsByServingEndpointId(ctx context.Cont // Retrieve all serving endpoints. // // This method is generated by Databricks SDK Code Generator. -func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListEndpointsResponse, ServingEndpoint] { +func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListEndpointsResponse, ServingEndpoint] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListEndpointsResponse, error) { diff --git a/service/settings/api.go b/service/settings/api.go index 8a0581bd7..1cf8685e1 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -117,7 +117,7 @@ func (a *AccountIpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAcc // Gets all IP access lists for the specified account. // // This method is generated by Databricks SDK Code Generator. -func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *GetIpAccessListsResponse, IpAccessListInfo] { +func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *GetIpAccessListsResponse, IpAccessListInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetIpAccessListsResponse, error) { @@ -434,7 +434,7 @@ func (a *IpAccessListsAPI) GetByIpAccessListId(ctx context.Context, ipAccessList // Gets all IP access lists for the specified workspace. // // This method is generated by Databricks SDK Code Generator. -func (a *IpAccessListsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListIpAccessListResponse, IpAccessListInfo] { +func (a *IpAccessListsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListIpAccessListResponse, IpAccessListInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListIpAccessListResponse, error) { @@ -697,7 +697,7 @@ func (a *TokenManagementAPI) GetPermissions(ctx context.Context) (*TokenPermissi // Lists all tokens associated with the specified workspace or user. // // This method is generated by Databricks SDK Code Generator. -func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManagementRequest) *listing.IteratorImpl[ListTokenManagementRequest, *ListTokensResponse, TokenInfo] { +func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManagementRequest) *listing.PaginatingIterator[ListTokenManagementRequest, *ListTokensResponse, TokenInfo] { getNextPage := func(ctx context.Context, req ListTokenManagementRequest) (*ListTokensResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -859,7 +859,7 @@ func (a *TokensAPI) DeleteByTokenId(ctx context.Context, tokenId string) error { // Lists all the valid tokens for a user-workspace pair. // // This method is generated by Databricks SDK Code Generator. -func (a *TokensAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListTokensResponse, TokenInfo] { +func (a *TokensAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListTokensResponse, TokenInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListTokensResponse, error) { diff --git a/service/sharing/api.go b/service/sharing/api.go index b38239b05..eb5169b7a 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -96,7 +96,7 @@ func (a *CleanRoomsAPI) GetByNameArg(ctx context.Context, nameArg string) (*Clea // a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) *listing.IteratorImpl[ListCleanRoomsRequest, *ListCleanRoomsResponse, CleanRoomInfo] { +func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) *listing.PaginatingIterator[ListCleanRoomsRequest, *ListCleanRoomsResponse, CleanRoomInfo] { getNextPage := func(ctx context.Context, req ListCleanRoomsRequest) (*ListCleanRoomsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -237,7 +237,7 @@ func (a *ProvidersAPI) GetByName(ctx context.Context, name string) (*ProviderInf // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) *listing.IteratorImpl[ListProvidersRequest, *ListProvidersResponse, ProviderInfo] { +func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) *listing.PaginatingIterator[ListProvidersRequest, *ListProvidersResponse, ProviderInfo] { getNextPage := func(ctx context.Context, req ListProvidersRequest) (*ListProvidersResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -300,7 +300,7 @@ func (a *ProvidersAPI) ProviderInfoNameToMetastoreIdMap(ctx context.Context, req // * the caller is a metastore admin, or * the caller is the owner. // // This method is generated by Databricks SDK Code Generator. -func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest) *listing.IteratorImpl[ListSharesRequest, *ListProviderSharesResponse, ProviderShare] { +func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest) *listing.PaginatingIterator[ListSharesRequest, *ListProviderSharesResponse, ProviderShare] { getNextPage := func(ctx context.Context, req ListSharesRequest) (*ListProviderSharesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -519,7 +519,7 @@ func (a *RecipientsAPI) GetByName(ctx context.Context, name string) (*RecipientI // guarantee of a specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) *listing.IteratorImpl[ListRecipientsRequest, *ListRecipientsResponse, RecipientInfo] { +func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) *listing.PaginatingIterator[ListRecipientsRequest, *ListRecipientsResponse, RecipientInfo] { getNextPage := func(ctx context.Context, req ListRecipientsRequest) (*ListRecipientsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -694,7 +694,7 @@ func (a *SharesAPI) GetByName(ctx context.Context, name string) (*ShareInfo, err // specific ordering of the elements in the array. // // This method is generated by Databricks SDK Code Generator. -func (a *SharesAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *ListSharesResponse, ShareInfo] { +func (a *SharesAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListSharesResponse, ShareInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListSharesResponse, error) { diff --git a/service/sql/api.go b/service/sql/api.go index bd6dd541d..db82c5a84 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -286,7 +286,7 @@ func (a *DashboardsAPI) GetByDashboardId(ctx context.Context, dashboardId string // Fetch a paginated list of dashboard objects. // // This method is generated by Databricks SDK Code Generator. -func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) *listing.DedupeIteratorImpl[Dashboard, string] { +func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) *listing.DeduplicatingIterator[Dashboard, string] { request.Page = 1 // start iterating from the first page @@ -309,7 +309,7 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) getNextPage, getItems, getNextReq) - dedupedIterator := listing.NewDedupeIterator( + dedupedIterator := listing.NewDedupeIterator[Dashboard, string]( iterator, func(item Dashboard) string { return item.Id @@ -649,7 +649,7 @@ func (a *QueriesAPI) GetByQueryId(ctx context.Context, queryId string) (*Query, // term. // // This method is generated by Databricks SDK Code Generator. -func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *listing.DedupeIteratorImpl[Query, string] { +func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *listing.DeduplicatingIterator[Query, string] { request.Page = 1 // start iterating from the first page @@ -672,7 +672,7 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *list getNextPage, getItems, getNextReq) - dedupedIterator := listing.NewDedupeIterator( + dedupedIterator := listing.NewDedupeIterator[Query, string]( iterator, func(item Query) string { return item.Id @@ -796,7 +796,7 @@ func (a *QueryHistoryAPI) Impl() QueryHistoryService { // You can filter by user ID, warehouse ID, status, and time range. // // This method is generated by Databricks SDK Code Generator. -func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequest) *listing.IteratorImpl[ListQueryHistoryRequest, *ListQueriesResponse, QueryInfo] { +func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequest) *listing.PaginatingIterator[ListQueryHistoryRequest, *ListQueriesResponse, QueryInfo] { getNextPage := func(ctx context.Context, req ListQueryHistoryRequest) (*ListQueriesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -1399,7 +1399,7 @@ func (a *WarehousesAPI) GetWorkspaceWarehouseConfig(ctx context.Context) (*GetWo // Lists all SQL warehouses that a user has manager permissions on. // // This method is generated by Databricks SDK Code Generator. -func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) *listing.IteratorImpl[ListWarehousesRequest, *ListWarehousesResponse, EndpointInfo] { +func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) *listing.PaginatingIterator[ListWarehousesRequest, *ListWarehousesResponse, EndpointInfo] { getNextPage := func(ctx context.Context, req ListWarehousesRequest) (*ListWarehousesResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") diff --git a/service/sql/model.go b/service/sql/model.go index d4db5f8a3..8e2fc3298 100755 --- a/service/sql/model.go +++ b/service/sql/model.go @@ -280,7 +280,6 @@ 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/workspace/api.go b/service/workspace/api.go index 446141b99..5f0a0437f 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -92,7 +92,7 @@ func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId // supported. // // This method is generated by Databricks SDK Code Generator. -func (a *GitCredentialsAPI) List(ctx context.Context) *listing.IteratorImpl[struct{}, *GetCredentialsResponse, CredentialInfo] { +func (a *GitCredentialsAPI) List(ctx context.Context) *listing.PaginatingIterator[struct{}, *GetCredentialsResponse, CredentialInfo] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*GetCredentialsResponse, error) { @@ -299,7 +299,7 @@ func (a *ReposAPI) GetPermissionsByRepoId(ctx context.Context, repoId string) (* // paginated with each page containing twenty repos. // // This method is generated by Databricks SDK Code Generator. -func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing.IteratorImpl[ListReposRequest, *ListReposResponse, RepoInfo] { +func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing.PaginatingIterator[ListReposRequest, *ListReposResponse, RepoInfo] { getNextPage := func(ctx context.Context, req ListReposRequest) (*ListReposResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -546,7 +546,7 @@ func (a *SecretsAPI) GetSecret(ctx context.Context, request GetSecretRequest) (* // call. // // This method is generated by Databricks SDK Code Generator. -func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *listing.IteratorImpl[ListAclsRequest, *ListAclsResponse, AclItem] { +func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *listing.PaginatingIterator[ListAclsRequest, *ListAclsResponse, AclItem] { getNextPage := func(ctx context.Context, req ListAclsRequest) (*ListAclsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -601,7 +601,7 @@ func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAc // API call. // // This method is generated by Databricks SDK Code Generator. -func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.IteratorImpl[struct{}, *ListScopesResponse, SecretScope] { +func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.PaginatingIterator[struct{}, *ListScopesResponse, SecretScope] { request := struct{}{} getNextPage := func(ctx context.Context, req struct{}) (*ListScopesResponse, error) { @@ -645,7 +645,7 @@ func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { // call. // // This method is generated by Databricks SDK Code Generator. -func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) *listing.IteratorImpl[ListSecretsRequest, *ListSecretsResponse, SecretMetadata] { +func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest) *listing.PaginatingIterator[ListSecretsRequest, *ListSecretsResponse, SecretMetadata] { getNextPage := func(ctx context.Context, req ListSecretsRequest) (*ListSecretsResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") @@ -885,7 +885,7 @@ func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error { // `RESOURCE_DOES_NOT_EXIST`. // // This method is generated by Databricks SDK Code Generator. -func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) *listing.IteratorImpl[ListWorkspaceRequest, *ListResponse, ObjectInfo] { +func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) *listing.PaginatingIterator[ListWorkspaceRequest, *ListResponse, ObjectInfo] { getNextPage := func(ctx context.Context, req ListWorkspaceRequest) (*ListResponse, error) { ctx = useragent.InContext(ctx, "sdk-feature", "pagination") From f9474fa9e81d7cafaefb2645c2848c9fb7d73197 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Mon, 23 Oct 2023 10:07:43 +0200 Subject: [PATCH 22/24] More type annotations --- .codegen/api.go.tmpl | 4 ++-- service/billing/api.go | 4 ++-- service/catalog/api.go | 30 ++++++++++++------------- service/compute/api.go | 16 ++++++------- service/files/api.go | 2 +- service/iam/api.go | 14 ++++++------ service/iam/model.go | 4 ++-- service/jobs/api.go | 4 ++-- service/ml/api.go | 22 +++++++++--------- service/ml/model_registry_usage_test.go | 26 ++++++++++----------- service/oauth2/api.go | 8 +++---- service/pipelines/api.go | 4 ++-- service/serving/api.go | 2 +- service/settings/api.go | 8 +++---- service/sharing/api.go | 10 ++++----- service/sql/api.go | 8 +++---- service/workspace/api.go | 12 +++++----- 17 files changed, 89 insertions(+), 89 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 444166d5f..844b99730 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -222,9 +222,9 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{ template "type" .Pagination.Entity }}, error) { iterator := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) {{ if .Pagination.Limit -}} - return listing.ToSliceN(ctx, iterator, request.{{.Pagination.Limit.PascalName}}) + return listing.ToSliceN[{{ template "type" .Pagination.Entity }}, {{ template "type" .Pagination.Limit.Entity }}](ctx, iterator, request.{{.Pagination.Limit.PascalName}}) {{ else -}} - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[{{ template "type" .Pagination.Entity }}](ctx, iterator) {{- end }} } {{end}}{{if .NamedIdMap}} diff --git a/service/billing/api.go b/service/billing/api.go index 3d06edd36..cab8f4913 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -158,7 +158,7 @@ func (a *BudgetsAPI) List(ctx context.Context) *listing.PaginatingIterator[struc // This method is generated by Databricks SDK Code Generator. func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[BudgetWithStatus](ctx, iterator) } // BudgetWithStatusNameToBudgetIdMap calls [BudgetsAPI.ListAll] and creates a map of results with [BudgetWithStatus].Name as key and [BudgetWithStatus].BudgetId as value. @@ -390,7 +390,7 @@ func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryReques // This method is generated by Databricks SDK Code Generator. func (a *LogDeliveryAPI) ListAll(ctx context.Context, request ListLogDeliveryRequest) ([]LogDeliveryConfiguration, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[LogDeliveryConfiguration](ctx, iterator) } // LogDeliveryConfigurationConfigNameToConfigIdMap calls [LogDeliveryAPI.ListAll] and creates a map of results with [LogDeliveryConfiguration].ConfigName as key and [LogDeliveryConfiguration].ConfigId as value. diff --git a/service/catalog/api.go b/service/catalog/api.go index a9874b661..22e9a98fa 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -119,7 +119,7 @@ func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListA // This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoreAssignmentsAPI) ListAll(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) ([]int64, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[int64](ctx, iterator) } // Get all workspaces assigned to a metastore. @@ -238,7 +238,7 @@ func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.PaginatingIter // This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[MetastoreInfo](ctx, iterator) } // Update a metastore. @@ -584,7 +584,7 @@ func (a *CatalogsAPI) List(ctx context.Context) *listing.PaginatingIterator[stru // This method is generated by Databricks SDK Code Generator. func (a *CatalogsAPI) ListAll(ctx context.Context) ([]CatalogInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[CatalogInfo](ctx, iterator) } // Update a catalog. @@ -707,7 +707,7 @@ func (a *ConnectionsAPI) List(ctx context.Context) *listing.PaginatingIterator[s // This method is generated by Databricks SDK Code Generator. func (a *ConnectionsAPI) ListAll(ctx context.Context) ([]ConnectionInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ConnectionInfo](ctx, iterator) } // ConnectionInfoNameToFullNameMap calls [ConnectionsAPI.ListAll] and creates a map of results with [ConnectionInfo].Name as key and [ConnectionInfo].FullName as value. @@ -895,7 +895,7 @@ func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.PaginatingIter // This method is generated by Databricks SDK Code Generator. func (a *ExternalLocationsAPI) ListAll(ctx context.Context) ([]ExternalLocationInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ExternalLocationInfo](ctx, iterator) } // Update an external location. @@ -1048,7 +1048,7 @@ func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) * // This method is generated by Databricks SDK Code Generator. func (a *FunctionsAPI) ListAll(ctx context.Context, request ListFunctionsRequest) ([]FunctionInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[FunctionInfo](ctx, iterator) } // FunctionInfoNameToFullNameMap calls [FunctionsAPI.ListAll] and creates a map of results with [FunctionInfo].Name as key and [FunctionInfo].FullName as value. @@ -1307,7 +1307,7 @@ func (a *MetastoresAPI) List(ctx context.Context) *listing.PaginatingIterator[st // This method is generated by Databricks SDK Code Generator. func (a *MetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[MetastoreInfo](ctx, iterator) } // MetastoreInfoNameToMetastoreIdMap calls [MetastoresAPI.ListAll] and creates a map of results with [MetastoreInfo].Name as key and [MetastoreInfo].MetastoreId as value. @@ -1580,7 +1580,7 @@ func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRe // This method is generated by Databricks SDK Code Generator. func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersionsRequest) ([]ModelVersionInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[ModelVersionInfo, int](ctx, iterator, request.MaxResults) } @@ -1830,7 +1830,7 @@ func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredMo // This method is generated by Databricks SDK Code Generator. func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegisteredModelsRequest) ([]RegisteredModelInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[RegisteredModelInfo, int](ctx, iterator, request.MaxResults) } @@ -2030,7 +2030,7 @@ func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *list // This method is generated by Databricks SDK Code Generator. func (a *SchemasAPI) ListAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[SchemaInfo](ctx, iterator) } // SchemaInfoNameToFullNameMap calls [SchemasAPI.ListAll] and creates a map of results with [SchemaInfo].Name as key and [SchemaInfo].FullName as value. @@ -2220,7 +2220,7 @@ func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.PaginatingIte // This method is generated by Databricks SDK Code Generator. func (a *StorageCredentialsAPI) ListAll(ctx context.Context) ([]StorageCredentialInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[StorageCredentialInfo](ctx, iterator) } // StorageCredentialInfoNameToIdMap calls [StorageCredentialsAPI.ListAll] and creates a map of results with [StorageCredentialInfo].Name as key and [StorageCredentialInfo].Id as value. @@ -2361,7 +2361,7 @@ func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRe // This method is generated by Databricks SDK Code Generator. func (a *SystemSchemasAPI) ListAll(ctx context.Context, request ListSystemSchemasRequest) ([]SystemSchemaInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[SystemSchemaInfo](ctx, iterator) } // List system schemas. @@ -2591,7 +2591,7 @@ func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listin // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[TableInfo, int](ctx, iterator, request.MaxResults) } @@ -2704,7 +2704,7 @@ func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequ // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesRequest) ([]TableSummary, error) { iterator := a.ListSummaries(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[TableSummary, int](ctx, iterator, request.MaxResults) } @@ -2853,7 +2853,7 @@ func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *list // This method is generated by Databricks SDK Code Generator. func (a *VolumesAPI) ListAll(ctx context.Context, request ListVolumesRequest) ([]VolumeInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[VolumeInfo](ctx, iterator) } // VolumeInfoNameToVolumeIdMap calls [VolumesAPI.ListAll] and creates a map of results with [VolumeInfo].Name as key and [VolumeInfo].VolumeId as value. diff --git a/service/compute/api.go b/service/compute/api.go index 5bb52a5d2..3170063e8 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -179,7 +179,7 @@ func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPolici // This method is generated by Databricks SDK Code Generator. func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request ListClusterPoliciesRequest) ([]Policy, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Policy](ctx, iterator) } // PolicyNameToPolicyIdMap calls [ClusterPoliciesAPI.ListAll] and creates a map of results with [Policy].Name as key and [Policy].PolicyId as value. @@ -638,7 +638,7 @@ func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.Pa // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) { iterator := a.Events(ctx, request) - return listing.ToSliceN(ctx, iterator, request.Limit) + return listing.ToSliceN[ClusterEvent, int64](ctx, iterator, request.Limit) } @@ -740,7 +740,7 @@ func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *li // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) ([]ClusterDetails, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ClusterDetails](ctx, iterator) } // ClusterDetailsClusterNameToClusterIdMap calls [ClustersAPI.ListAll] and creates a map of results with [ClusterDetails].ClusterName as key and [ClusterDetails].ClusterId as value. @@ -1578,7 +1578,7 @@ func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.PaginatingIter // This method is generated by Databricks SDK Code Generator. func (a *GlobalInitScriptsAPI) ListAll(ctx context.Context) ([]GlobalInitScriptDetails, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[GlobalInitScriptDetails](ctx, iterator) } // GlobalInitScriptDetailsNameToScriptIdMap calls [GlobalInitScriptsAPI.ListAll] and creates a map of results with [GlobalInitScriptDetails].Name as key and [GlobalInitScriptDetails].ScriptId as value. @@ -1799,7 +1799,7 @@ func (a *InstancePoolsAPI) List(ctx context.Context) *listing.PaginatingIterator // This method is generated by Databricks SDK Code Generator. func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[InstancePoolAndStats](ctx, iterator) } // InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap calls [InstancePoolsAPI.ListAll] and creates a map of results with [InstancePoolAndStats].InstancePoolName as key and [InstancePoolAndStats].InstancePoolId as value. @@ -1967,7 +1967,7 @@ func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.PaginatingItera // This method is generated by Databricks SDK Code Generator. func (a *InstanceProfilesAPI) ListAll(ctx context.Context) ([]InstanceProfile, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[InstanceProfile](ctx, iterator) } // Remove the instance profile. @@ -2106,7 +2106,7 @@ func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusR // This method is generated by Databricks SDK Code Generator. func (a *LibrariesAPI) ClusterStatusAll(ctx context.Context, request ClusterStatusRequest) ([]LibraryFullStatus, error) { iterator := a.ClusterStatus(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[LibraryFullStatus](ctx, iterator) } // Get status. @@ -2240,6 +2240,6 @@ func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamilies // This method is generated by Databricks SDK Code Generator. func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamiliesRequest) ([]PolicyFamily, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[PolicyFamily, int64](ctx, iterator, request.MaxResults) } diff --git a/service/files/api.go b/service/files/api.go index 0e394761b..6f4353001 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -177,7 +177,7 @@ func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.Pa // This method is generated by Databricks SDK Code Generator. func (a *DbfsAPI) ListAll(ctx context.Context, request ListDbfsRequest) ([]FileInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[FileInfo](ctx, iterator) } // List directory contents or file details. diff --git a/service/iam/api.go b/service/iam/api.go index 4fdf5379e..5c6b1d027 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -228,7 +228,7 @@ func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRe // This method is generated by Databricks SDK Code Generator. func (a *AccountGroupsAPI) ListAll(ctx context.Context, request ListAccountGroupsRequest) ([]Group, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Group](ctx, iterator) } // GroupDisplayNameToIdMap calls [AccountGroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -401,7 +401,7 @@ func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAcco // This method is generated by Databricks SDK Code Generator. func (a *AccountServicePrincipalsAPI) ListAll(ctx context.Context, request ListAccountServicePrincipalsRequest) ([]ServicePrincipal, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ServicePrincipal](ctx, iterator) } // ServicePrincipalDisplayNameToIdMap calls [AccountServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -583,7 +583,7 @@ func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequ // This method is generated by Databricks SDK Code Generator. func (a *AccountUsersAPI) ListAll(ctx context.Context, request ListAccountUsersRequest) ([]User, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[User](ctx, iterator) } // UserUserNameToIdMap calls [AccountUsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -792,7 +792,7 @@ func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listin // This method is generated by Databricks SDK Code Generator. func (a *GroupsAPI) ListAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Group](ctx, iterator) } // GroupDisplayNameToIdMap calls [GroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -1090,7 +1090,7 @@ func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrin // This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalsAPI) ListAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ServicePrincipal](ctx, iterator) } // ServicePrincipalDisplayNameToIdMap calls [ServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -1287,7 +1287,7 @@ func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing. // This method is generated by Databricks SDK Code Generator. func (a *UsersAPI) ListAll(ctx context.Context, request ListUsersRequest) ([]User, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[User](ctx, iterator) } // UserUserNameToIdMap calls [UsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -1471,7 +1471,7 @@ func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspace // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorkspaceAssignmentRequest) ([]PermissionAssignment, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[PermissionAssignment](ctx, iterator) } // Get permission assignments. diff --git a/service/iam/model.go b/service/iam/model.go index 4d1a0f3d0..f08919356 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,7 @@ type Group struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks group ID - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Members []ComplexValue `json:"members,omitempty"` // Container for the group identifier. Workspace local versus account. @@ -1070,7 +1070,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 a2a1046ab..3fc54c127 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -359,7 +359,7 @@ func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.Pa // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJob, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.Limit) + return listing.ToSliceN[BaseJob, int](ctx, iterator, request.Limit) } @@ -452,7 +452,7 @@ func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listin // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]BaseRun, error) { iterator := a.ListRuns(ctx, request) - return listing.ToSliceN(ctx, iterator, request.Limit) + return listing.ToSliceN[BaseRun, int](ctx, iterator, request.Limit) } diff --git a/service/ml/api.go b/service/ml/api.go index 71fd67333..a01153788 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -158,7 +158,7 @@ func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryReque // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRequest) ([]Metric, error) { iterator := a.GetHistory(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[Metric, int](ctx, iterator, request.MaxResults) } @@ -246,7 +246,7 @@ func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifact // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) { iterator := a.ListArtifacts(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[FileInfo](ctx, iterator) } // List experiments. @@ -285,7 +285,7 @@ func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperi // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) { iterator := a.ListExperiments(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[Experiment, int](ctx, iterator, request.MaxResults) } @@ -430,7 +430,7 @@ func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchEx // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) { iterator := a.SearchExperiments(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Experiment](ctx, iterator) } // Search for runs. @@ -473,7 +473,7 @@ func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *li // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) ([]Run, error) { iterator := a.SearchRuns(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Run](ctx, iterator) } // Set a tag. @@ -680,7 +680,7 @@ func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLat // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) { iterator := a.GetLatestVersions(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ModelVersion](ctx, iterator) } // Get model. @@ -780,7 +780,7 @@ func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsReq // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModelsRequest) ([]Model, error) { iterator := a.ListModels(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[Model, int](ctx, iterator, request.MaxResults) } @@ -814,7 +814,7 @@ func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request L // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, request ListTransitionRequestsRequest) ([]Activity, error) { iterator := a.ListTransitionRequests(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Activity](ctx, iterator) } // List registry webhooks. @@ -857,7 +857,7 @@ func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhook // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebhooksRequest) ([]RegistryWebhook, error) { iterator := a.ListWebhooks(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[RegistryWebhook](ctx, iterator) } // Reject a transition request. @@ -910,7 +910,7 @@ func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request Sear // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) { iterator := a.SearchModelVersions(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[ModelVersion, int](ctx, iterator, request.MaxResults) } @@ -950,7 +950,7 @@ func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModel // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchModelsRequest) ([]Model, error) { iterator := a.SearchModels(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[Model, int](ctx, iterator, request.MaxResults) } diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index ff3c69793..b5ccf9028 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -58,24 +58,24 @@ func ExampleModelRegistryAPI_CreateComment_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_modelVersions() { +func ExampleModelRegistryAPI_CreateModel_models() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", model) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -92,24 +92,24 @@ func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_models() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", model) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -124,18 +124,18 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { } logger.Infof(ctx, "found %v", model) - created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", mv) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -150,14 +150,14 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { } logger.Infof(ctx, "found %v", model) - mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", mv) + logger.Infof(ctx, "found %v", created) } diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 0e9a0e8ba..62cc1431b 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -117,7 +117,7 @@ func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.PaginatingI // This method is generated by Databricks SDK Code Generator. func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIntegrationOutput, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[GetCustomAppIntegrationOutput](ctx, iterator) } // Updates Custom OAuth App Integration. @@ -250,7 +250,7 @@ func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPubli // This method is generated by Databricks SDK Code Generator. func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPublishedAppsRequest) ([]PublishedAppOutput, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.PageSize) + return listing.ToSliceN[PublishedAppOutput, int64](ctx, iterator, request.PageSize) } @@ -360,7 +360,7 @@ func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.Paginati // This method is generated by Databricks SDK Code Generator. func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishedAppIntegrationOutput, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[GetPublishedAppIntegrationOutput](ctx, iterator) } // Updates Published OAuth App Integration. @@ -468,7 +468,7 @@ func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServi // This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalSecretsAPI) ListAll(ctx context.Context, request ListServicePrincipalSecretsRequest) ([]SecretInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[SecretInfo](ctx, iterator) } // List service principal secrets. diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 1162d81c4..b3f445388 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -285,7 +285,7 @@ func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipel // This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPipelineEventsRequest) ([]PipelineEvent, error) { iterator := a.ListPipelineEvents(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[PipelineEvent, int](ctx, iterator, request.MaxResults) } @@ -334,7 +334,7 @@ func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesR // This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelinesRequest) ([]PipelineStateInfo, error) { iterator := a.ListPipelines(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[PipelineStateInfo, int](ctx, iterator, request.MaxResults) } diff --git a/service/serving/api.go b/service/serving/api.go index 05d3ba9d6..7c62111e4 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -277,7 +277,7 @@ func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.PaginatingItera // This method is generated by Databricks SDK Code Generator. func (a *ServingEndpointsAPI) ListAll(ctx context.Context) ([]ServingEndpoint, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ServingEndpoint](ctx, iterator) } // Retrieve the most recent log lines associated with a given serving endpoint's diff --git a/service/settings/api.go b/service/settings/api.go index 1cf8685e1..2987ce7b8 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -143,7 +143,7 @@ func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.PaginatingI // This method is generated by Databricks SDK Code Generator. func (a *AccountIpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[IpAccessListInfo](ctx, iterator) } // IpAccessListInfoLabelToListIdMap calls [AccountIpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -460,7 +460,7 @@ func (a *IpAccessListsAPI) List(ctx context.Context) *listing.PaginatingIterator // This method is generated by Databricks SDK Code Generator. func (a *IpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[IpAccessListInfo](ctx, iterator) } // IpAccessListInfoLabelToListIdMap calls [IpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -722,7 +722,7 @@ func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManageme // This method is generated by Databricks SDK Code Generator. func (a *TokenManagementAPI) ListAll(ctx context.Context, request ListTokenManagementRequest) ([]TokenInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[TokenInfo](ctx, iterator) } // TokenInfoCommentToTokenIdMap calls [TokenManagementAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. @@ -885,7 +885,7 @@ func (a *TokensAPI) List(ctx context.Context) *listing.PaginatingIterator[struct // This method is generated by Databricks SDK Code Generator. func (a *TokensAPI) ListAll(ctx context.Context) ([]TokenInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[TokenInfo](ctx, iterator) } // TokenInfoCommentToTokenIdMap calls [TokensAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. diff --git a/service/sharing/api.go b/service/sharing/api.go index eb5169b7a..3cf721818 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -129,7 +129,7 @@ func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) // This method is generated by Databricks SDK Code Generator. func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsRequest) ([]CleanRoomInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[CleanRoomInfo, int](ctx, iterator, request.MaxResults) } @@ -265,7 +265,7 @@ func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) * // This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ProviderInfo](ctx, iterator) } // ProviderInfoNameToMetastoreIdMap calls [ProvidersAPI.ListAll] and creates a map of results with [ProviderInfo].Name as key and [ProviderInfo].MetastoreId as value. @@ -327,7 +327,7 @@ func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest // This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListSharesAll(ctx context.Context, request ListSharesRequest) ([]ProviderShare, error) { iterator := a.ListShares(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ProviderShare](ctx, iterator) } // List shares by Provider. @@ -547,7 +547,7 @@ func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) // This method is generated by Databricks SDK Code Generator. func (a *RecipientsAPI) ListAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[RecipientInfo](ctx, iterator) } // RecipientInfoNameToMetastoreIdMap calls [RecipientsAPI.ListAll] and creates a map of results with [RecipientInfo].Name as key and [RecipientInfo].MetastoreId as value. @@ -722,7 +722,7 @@ func (a *SharesAPI) List(ctx context.Context) *listing.PaginatingIterator[struct // This method is generated by Databricks SDK Code Generator. func (a *SharesAPI) ListAll(ctx context.Context) ([]ShareInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ShareInfo](ctx, iterator) } // Get permissions. diff --git a/service/sql/api.go b/service/sql/api.go index db82c5a84..c461b658a 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -324,7 +324,7 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) // This method is generated by Databricks SDK Code Generator. func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.PageSize) + return listing.ToSliceN[Dashboard, int](ctx, iterator, request.PageSize) } @@ -688,7 +688,7 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *list // This method is generated by Databricks SDK Code Generator. func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.PageSize) + return listing.ToSliceN[Query, int](ctx, iterator, request.PageSize) } @@ -829,7 +829,7 @@ func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequ // This method is generated by Databricks SDK Code Generator. func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[QueryInfo, int](ctx, iterator, request.MaxResults) } @@ -1424,7 +1424,7 @@ func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) // This method is generated by Databricks SDK Code Generator. func (a *WarehousesAPI) ListAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[EndpointInfo](ctx, iterator) } // EndpointInfoNameToIdMap calls [WarehousesAPI.ListAll] and creates a map of results with [EndpointInfo].Name as key and [EndpointInfo].Id as value. diff --git a/service/workspace/api.go b/service/workspace/api.go index 5f0a0437f..cd70b2948 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -119,7 +119,7 @@ func (a *GitCredentialsAPI) List(ctx context.Context) *listing.PaginatingIterato // This method is generated by Databricks SDK Code Generator. func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[CredentialInfo](ctx, iterator) } // CredentialInfoGitProviderToCredentialIdMap calls [GitCredentialsAPI.ListAll] and creates a map of results with [CredentialInfo].GitProvider as key and [CredentialInfo].CredentialId as value. @@ -331,7 +331,7 @@ func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing. // This method is generated by Databricks SDK Code Generator. func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[RepoInfo](ctx, iterator) } // RepoInfoPathToIdMap calls [ReposAPI.ListAll] and creates a map of results with [RepoInfo].Path as key and [RepoInfo].Id as value. @@ -576,7 +576,7 @@ func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *lis // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) { iterator := a.ListAcls(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[AclItem](ctx, iterator) } // Lists ACLs. @@ -630,7 +630,7 @@ func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.PaginatingIterator // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { iterator := a.ListScopes(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[SecretScope](ctx, iterator) } // List secret keys. @@ -677,7 +677,7 @@ func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) { iterator := a.ListSecrets(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[SecretMetadata](ctx, iterator) } // List secret keys. @@ -912,7 +912,7 @@ func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) * // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ObjectInfo](ctx, iterator) } // ObjectInfoPathToObjectIdMap calls [WorkspaceAPI.ListAll] and creates a map of results with [ObjectInfo].Path as key and [ObjectInfo].ObjectId as value. From a84080d4a62a4de97f0d4e0e1af9f526252a922b Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Mon, 23 Oct 2023 10:10:54 +0200 Subject: [PATCH 23/24] 0.4.6 staticcheck --- .codegen/api.go.tmpl | 6 ++--- Makefile | 2 +- service/billing/api.go | 4 ++-- service/catalog/api.go | 30 ++++++++++++------------- service/compute/api.go | 16 ++++++------- service/files/api.go | 2 +- service/iam/api.go | 14 ++++++------ service/iam/model.go | 6 ++--- service/jobs/api.go | 4 ++-- service/ml/api.go | 22 +++++++++--------- service/ml/model_registry_usage_test.go | 24 ++++++++++---------- service/oauth2/api.go | 8 +++---- service/pipelines/api.go | 4 ++-- service/serving/api.go | 2 +- service/settings/api.go | 8 +++---- service/sharing/api.go | 10 ++++----- service/sql/api.go | 12 +++++----- service/workspace/api.go | 12 +++++----- 18 files changed, 93 insertions(+), 93 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index 844b99730..a43ca80f5 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -205,7 +205,7 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} getItems, {{if .Pagination.MultiRequest}}getNextReq{{else}}nil{{end}}) {{ if .NeedsOffsetDedupe -}} - dedupedIterator := listing.NewDedupeIterator[{{ template "type" .Pagination.Entity }}, {{ template "type" .IdentifierField.Entity }}]( + dedupedIterator := listing.NewDedupeIterator( iterator, func(item {{ template "type" .Pagination.Entity }}) {{ template "type" .IdentifierField.Entity }} { return item{{ template "field-path" .IdFieldPath }} @@ -222,9 +222,9 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{ template "type" .Pagination.Entity }}, error) { iterator := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) {{ if .Pagination.Limit -}} - return listing.ToSliceN[{{ template "type" .Pagination.Entity }}, {{ template "type" .Pagination.Limit.Entity }}](ctx, iterator, request.{{.Pagination.Limit.PascalName}}) + return listing.ToSliceN(ctx, iterator, request.{{.Pagination.Limit.PascalName}}) {{ else -}} - return listing.ToSlice[{{ template "type" .Pagination.Entity }}](ctx, iterator) + return listing.ToSlice(ctx, iterator) {{- end }} } {{end}}{{if .NamedIdMap}} diff --git a/Makefile b/Makefile index 57bf25ddd..43b5e4a5d 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ fmt: lint: vendor @echo "✓ Linting source code with https://staticcheck.io/ ..." - @go run honnef.co/go/tools/cmd/staticcheck@v0.4.0 ./... + @go run honnef.co/go/tools/cmd/staticcheck@v0.4.6 ./... test: lint @echo "✓ Running tests ..." diff --git a/service/billing/api.go b/service/billing/api.go index cab8f4913..3d06edd36 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -158,7 +158,7 @@ func (a *BudgetsAPI) List(ctx context.Context) *listing.PaginatingIterator[struc // This method is generated by Databricks SDK Code Generator. func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { iterator := a.List(ctx) - return listing.ToSlice[BudgetWithStatus](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // BudgetWithStatusNameToBudgetIdMap calls [BudgetsAPI.ListAll] and creates a map of results with [BudgetWithStatus].Name as key and [BudgetWithStatus].BudgetId as value. @@ -390,7 +390,7 @@ func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryReques // This method is generated by Databricks SDK Code Generator. func (a *LogDeliveryAPI) ListAll(ctx context.Context, request ListLogDeliveryRequest) ([]LogDeliveryConfiguration, error) { iterator := a.List(ctx, request) - return listing.ToSlice[LogDeliveryConfiguration](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // LogDeliveryConfigurationConfigNameToConfigIdMap calls [LogDeliveryAPI.ListAll] and creates a map of results with [LogDeliveryConfiguration].ConfigName as key and [LogDeliveryConfiguration].ConfigId as value. diff --git a/service/catalog/api.go b/service/catalog/api.go index 22e9a98fa..a9874b661 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -119,7 +119,7 @@ func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListA // This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoreAssignmentsAPI) ListAll(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) ([]int64, error) { iterator := a.List(ctx, request) - return listing.ToSlice[int64](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Get all workspaces assigned to a metastore. @@ -238,7 +238,7 @@ func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.PaginatingIter // This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[MetastoreInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Update a metastore. @@ -584,7 +584,7 @@ func (a *CatalogsAPI) List(ctx context.Context) *listing.PaginatingIterator[stru // This method is generated by Databricks SDK Code Generator. func (a *CatalogsAPI) ListAll(ctx context.Context) ([]CatalogInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[CatalogInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Update a catalog. @@ -707,7 +707,7 @@ func (a *ConnectionsAPI) List(ctx context.Context) *listing.PaginatingIterator[s // This method is generated by Databricks SDK Code Generator. func (a *ConnectionsAPI) ListAll(ctx context.Context) ([]ConnectionInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[ConnectionInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // ConnectionInfoNameToFullNameMap calls [ConnectionsAPI.ListAll] and creates a map of results with [ConnectionInfo].Name as key and [ConnectionInfo].FullName as value. @@ -895,7 +895,7 @@ func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.PaginatingIter // This method is generated by Databricks SDK Code Generator. func (a *ExternalLocationsAPI) ListAll(ctx context.Context) ([]ExternalLocationInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[ExternalLocationInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Update an external location. @@ -1048,7 +1048,7 @@ func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) * // This method is generated by Databricks SDK Code Generator. func (a *FunctionsAPI) ListAll(ctx context.Context, request ListFunctionsRequest) ([]FunctionInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[FunctionInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // FunctionInfoNameToFullNameMap calls [FunctionsAPI.ListAll] and creates a map of results with [FunctionInfo].Name as key and [FunctionInfo].FullName as value. @@ -1307,7 +1307,7 @@ func (a *MetastoresAPI) List(ctx context.Context) *listing.PaginatingIterator[st // This method is generated by Databricks SDK Code Generator. func (a *MetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[MetastoreInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // MetastoreInfoNameToMetastoreIdMap calls [MetastoresAPI.ListAll] and creates a map of results with [MetastoreInfo].Name as key and [MetastoreInfo].MetastoreId as value. @@ -1580,7 +1580,7 @@ func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRe // This method is generated by Databricks SDK Code Generator. func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersionsRequest) ([]ModelVersionInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[ModelVersionInfo, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -1830,7 +1830,7 @@ func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredMo // This method is generated by Databricks SDK Code Generator. func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegisteredModelsRequest) ([]RegisteredModelInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[RegisteredModelInfo, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -2030,7 +2030,7 @@ func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *list // This method is generated by Databricks SDK Code Generator. func (a *SchemasAPI) ListAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[SchemaInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // SchemaInfoNameToFullNameMap calls [SchemasAPI.ListAll] and creates a map of results with [SchemaInfo].Name as key and [SchemaInfo].FullName as value. @@ -2220,7 +2220,7 @@ func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.PaginatingIte // This method is generated by Databricks SDK Code Generator. func (a *StorageCredentialsAPI) ListAll(ctx context.Context) ([]StorageCredentialInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[StorageCredentialInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // StorageCredentialInfoNameToIdMap calls [StorageCredentialsAPI.ListAll] and creates a map of results with [StorageCredentialInfo].Name as key and [StorageCredentialInfo].Id as value. @@ -2361,7 +2361,7 @@ func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRe // This method is generated by Databricks SDK Code Generator. func (a *SystemSchemasAPI) ListAll(ctx context.Context, request ListSystemSchemasRequest) ([]SystemSchemaInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[SystemSchemaInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // List system schemas. @@ -2591,7 +2591,7 @@ func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listin // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[TableInfo, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -2704,7 +2704,7 @@ func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequ // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesRequest) ([]TableSummary, error) { iterator := a.ListSummaries(ctx, request) - return listing.ToSliceN[TableSummary, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -2853,7 +2853,7 @@ func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *list // This method is generated by Databricks SDK Code Generator. func (a *VolumesAPI) ListAll(ctx context.Context, request ListVolumesRequest) ([]VolumeInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[VolumeInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // VolumeInfoNameToVolumeIdMap calls [VolumesAPI.ListAll] and creates a map of results with [VolumeInfo].Name as key and [VolumeInfo].VolumeId as value. diff --git a/service/compute/api.go b/service/compute/api.go index 3170063e8..5bb52a5d2 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -179,7 +179,7 @@ func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPolici // This method is generated by Databricks SDK Code Generator. func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request ListClusterPoliciesRequest) ([]Policy, error) { iterator := a.List(ctx, request) - return listing.ToSlice[Policy](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // PolicyNameToPolicyIdMap calls [ClusterPoliciesAPI.ListAll] and creates a map of results with [Policy].Name as key and [Policy].PolicyId as value. @@ -638,7 +638,7 @@ func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.Pa // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) { iterator := a.Events(ctx, request) - return listing.ToSliceN[ClusterEvent, int64](ctx, iterator, request.Limit) + return listing.ToSliceN(ctx, iterator, request.Limit) } @@ -740,7 +740,7 @@ func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *li // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) ([]ClusterDetails, error) { iterator := a.List(ctx, request) - return listing.ToSlice[ClusterDetails](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // ClusterDetailsClusterNameToClusterIdMap calls [ClustersAPI.ListAll] and creates a map of results with [ClusterDetails].ClusterName as key and [ClusterDetails].ClusterId as value. @@ -1578,7 +1578,7 @@ func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.PaginatingIter // This method is generated by Databricks SDK Code Generator. func (a *GlobalInitScriptsAPI) ListAll(ctx context.Context) ([]GlobalInitScriptDetails, error) { iterator := a.List(ctx) - return listing.ToSlice[GlobalInitScriptDetails](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // GlobalInitScriptDetailsNameToScriptIdMap calls [GlobalInitScriptsAPI.ListAll] and creates a map of results with [GlobalInitScriptDetails].Name as key and [GlobalInitScriptDetails].ScriptId as value. @@ -1799,7 +1799,7 @@ func (a *InstancePoolsAPI) List(ctx context.Context) *listing.PaginatingIterator // This method is generated by Databricks SDK Code Generator. func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, error) { iterator := a.List(ctx) - return listing.ToSlice[InstancePoolAndStats](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap calls [InstancePoolsAPI.ListAll] and creates a map of results with [InstancePoolAndStats].InstancePoolName as key and [InstancePoolAndStats].InstancePoolId as value. @@ -1967,7 +1967,7 @@ func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.PaginatingItera // This method is generated by Databricks SDK Code Generator. func (a *InstanceProfilesAPI) ListAll(ctx context.Context) ([]InstanceProfile, error) { iterator := a.List(ctx) - return listing.ToSlice[InstanceProfile](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Remove the instance profile. @@ -2106,7 +2106,7 @@ func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusR // This method is generated by Databricks SDK Code Generator. func (a *LibrariesAPI) ClusterStatusAll(ctx context.Context, request ClusterStatusRequest) ([]LibraryFullStatus, error) { iterator := a.ClusterStatus(ctx, request) - return listing.ToSlice[LibraryFullStatus](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Get status. @@ -2240,6 +2240,6 @@ func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamilies // This method is generated by Databricks SDK Code Generator. func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamiliesRequest) ([]PolicyFamily, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[PolicyFamily, int64](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } diff --git a/service/files/api.go b/service/files/api.go index 6f4353001..0e394761b 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -177,7 +177,7 @@ func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.Pa // This method is generated by Databricks SDK Code Generator. func (a *DbfsAPI) ListAll(ctx context.Context, request ListDbfsRequest) ([]FileInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[FileInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // List directory contents or file details. diff --git a/service/iam/api.go b/service/iam/api.go index 5c6b1d027..4fdf5379e 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -228,7 +228,7 @@ func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRe // This method is generated by Databricks SDK Code Generator. func (a *AccountGroupsAPI) ListAll(ctx context.Context, request ListAccountGroupsRequest) ([]Group, error) { iterator := a.List(ctx, request) - return listing.ToSlice[Group](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // GroupDisplayNameToIdMap calls [AccountGroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -401,7 +401,7 @@ func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAcco // This method is generated by Databricks SDK Code Generator. func (a *AccountServicePrincipalsAPI) ListAll(ctx context.Context, request ListAccountServicePrincipalsRequest) ([]ServicePrincipal, error) { iterator := a.List(ctx, request) - return listing.ToSlice[ServicePrincipal](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // ServicePrincipalDisplayNameToIdMap calls [AccountServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -583,7 +583,7 @@ func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequ // This method is generated by Databricks SDK Code Generator. func (a *AccountUsersAPI) ListAll(ctx context.Context, request ListAccountUsersRequest) ([]User, error) { iterator := a.List(ctx, request) - return listing.ToSlice[User](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // UserUserNameToIdMap calls [AccountUsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -792,7 +792,7 @@ func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listin // This method is generated by Databricks SDK Code Generator. func (a *GroupsAPI) ListAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { iterator := a.List(ctx, request) - return listing.ToSlice[Group](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // GroupDisplayNameToIdMap calls [GroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -1090,7 +1090,7 @@ func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrin // This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalsAPI) ListAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { iterator := a.List(ctx, request) - return listing.ToSlice[ServicePrincipal](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // ServicePrincipalDisplayNameToIdMap calls [ServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -1287,7 +1287,7 @@ func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing. // This method is generated by Databricks SDK Code Generator. func (a *UsersAPI) ListAll(ctx context.Context, request ListUsersRequest) ([]User, error) { iterator := a.List(ctx, request) - return listing.ToSlice[User](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // UserUserNameToIdMap calls [UsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -1471,7 +1471,7 @@ func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspace // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorkspaceAssignmentRequest) ([]PermissionAssignment, error) { iterator := a.List(ctx, request) - return listing.ToSlice[PermissionAssignment](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Get permission assignments. diff --git a/service/iam/model.go b/service/iam/model.go index f08919356..f13094f41 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,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. @@ -1024,7 +1024,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Roles []ComplexValue `json:"roles,omitempty"` @@ -1070,7 +1070,7 @@ type User struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks user ID. - Id string `json:"id,omitempty" url:"-"` + Id string `json:"id,omitempty"` Name *Name `json:"name,omitempty"` diff --git a/service/jobs/api.go b/service/jobs/api.go index 3fc54c127..a2a1046ab 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -359,7 +359,7 @@ func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.Pa // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJob, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[BaseJob, int](ctx, iterator, request.Limit) + return listing.ToSliceN(ctx, iterator, request.Limit) } @@ -452,7 +452,7 @@ func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listin // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]BaseRun, error) { iterator := a.ListRuns(ctx, request) - return listing.ToSliceN[BaseRun, int](ctx, iterator, request.Limit) + return listing.ToSliceN(ctx, iterator, request.Limit) } diff --git a/service/ml/api.go b/service/ml/api.go index a01153788..71fd67333 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -158,7 +158,7 @@ func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryReque // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRequest) ([]Metric, error) { iterator := a.GetHistory(ctx, request) - return listing.ToSliceN[Metric, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -246,7 +246,7 @@ func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifact // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) { iterator := a.ListArtifacts(ctx, request) - return listing.ToSlice[FileInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // List experiments. @@ -285,7 +285,7 @@ func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperi // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) { iterator := a.ListExperiments(ctx, request) - return listing.ToSliceN[Experiment, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -430,7 +430,7 @@ func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchEx // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) { iterator := a.SearchExperiments(ctx, request) - return listing.ToSlice[Experiment](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Search for runs. @@ -473,7 +473,7 @@ func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *li // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) ([]Run, error) { iterator := a.SearchRuns(ctx, request) - return listing.ToSlice[Run](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Set a tag. @@ -680,7 +680,7 @@ func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLat // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) { iterator := a.GetLatestVersions(ctx, request) - return listing.ToSlice[ModelVersion](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Get model. @@ -780,7 +780,7 @@ func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsReq // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModelsRequest) ([]Model, error) { iterator := a.ListModels(ctx, request) - return listing.ToSliceN[Model, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -814,7 +814,7 @@ func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request L // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, request ListTransitionRequestsRequest) ([]Activity, error) { iterator := a.ListTransitionRequests(ctx, request) - return listing.ToSlice[Activity](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // List registry webhooks. @@ -857,7 +857,7 @@ func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhook // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebhooksRequest) ([]RegistryWebhook, error) { iterator := a.ListWebhooks(ctx, request) - return listing.ToSlice[RegistryWebhook](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Reject a transition request. @@ -910,7 +910,7 @@ func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request Sear // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) { iterator := a.SearchModelVersions(ctx, request) - return listing.ToSliceN[ModelVersion, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -950,7 +950,7 @@ func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModel // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchModelsRequest) ([]Model, error) { iterator := a.SearchModels(ctx, request) - return listing.ToSliceN[Model, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index b5ccf9028..393ab2811 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -58,20 +58,20 @@ func ExampleModelRegistryAPI_CreateComment_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_models() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", model) } @@ -92,24 +92,24 @@ func ExampleModelRegistryAPI_CreateModel_modelVersions() { } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_models() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", model) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -124,18 +124,18 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { } logger.Infof(ctx, "found %v", model) - mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", mv) + logger.Infof(ctx, "found %v", created) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -150,14 +150,14 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { } logger.Infof(ctx, "found %v", model) - created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", mv) } diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 62cc1431b..0e9a0e8ba 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -117,7 +117,7 @@ func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.PaginatingI // This method is generated by Databricks SDK Code Generator. func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIntegrationOutput, error) { iterator := a.List(ctx) - return listing.ToSlice[GetCustomAppIntegrationOutput](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Updates Custom OAuth App Integration. @@ -250,7 +250,7 @@ func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPubli // This method is generated by Databricks SDK Code Generator. func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPublishedAppsRequest) ([]PublishedAppOutput, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[PublishedAppOutput, int64](ctx, iterator, request.PageSize) + return listing.ToSliceN(ctx, iterator, request.PageSize) } @@ -360,7 +360,7 @@ func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.Paginati // This method is generated by Databricks SDK Code Generator. func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishedAppIntegrationOutput, error) { iterator := a.List(ctx) - return listing.ToSlice[GetPublishedAppIntegrationOutput](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Updates Published OAuth App Integration. @@ -468,7 +468,7 @@ func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServi // This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalSecretsAPI) ListAll(ctx context.Context, request ListServicePrincipalSecretsRequest) ([]SecretInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[SecretInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // List service principal secrets. diff --git a/service/pipelines/api.go b/service/pipelines/api.go index b3f445388..1162d81c4 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -285,7 +285,7 @@ func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipel // This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPipelineEventsRequest) ([]PipelineEvent, error) { iterator := a.ListPipelineEvents(ctx, request) - return listing.ToSliceN[PipelineEvent, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -334,7 +334,7 @@ func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesR // This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelinesRequest) ([]PipelineStateInfo, error) { iterator := a.ListPipelines(ctx, request) - return listing.ToSliceN[PipelineStateInfo, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } diff --git a/service/serving/api.go b/service/serving/api.go index 7c62111e4..05d3ba9d6 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -277,7 +277,7 @@ func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.PaginatingItera // This method is generated by Databricks SDK Code Generator. func (a *ServingEndpointsAPI) ListAll(ctx context.Context) ([]ServingEndpoint, error) { iterator := a.List(ctx) - return listing.ToSlice[ServingEndpoint](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Retrieve the most recent log lines associated with a given serving endpoint's diff --git a/service/settings/api.go b/service/settings/api.go index 2987ce7b8..1cf8685e1 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -143,7 +143,7 @@ func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.PaginatingI // This method is generated by Databricks SDK Code Generator. func (a *AccountIpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[IpAccessListInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // IpAccessListInfoLabelToListIdMap calls [AccountIpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -460,7 +460,7 @@ func (a *IpAccessListsAPI) List(ctx context.Context) *listing.PaginatingIterator // This method is generated by Databricks SDK Code Generator. func (a *IpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[IpAccessListInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // IpAccessListInfoLabelToListIdMap calls [IpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -722,7 +722,7 @@ func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManageme // This method is generated by Databricks SDK Code Generator. func (a *TokenManagementAPI) ListAll(ctx context.Context, request ListTokenManagementRequest) ([]TokenInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[TokenInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // TokenInfoCommentToTokenIdMap calls [TokenManagementAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. @@ -885,7 +885,7 @@ func (a *TokensAPI) List(ctx context.Context) *listing.PaginatingIterator[struct // This method is generated by Databricks SDK Code Generator. func (a *TokensAPI) ListAll(ctx context.Context) ([]TokenInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[TokenInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // TokenInfoCommentToTokenIdMap calls [TokensAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. diff --git a/service/sharing/api.go b/service/sharing/api.go index 3cf721818..eb5169b7a 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -129,7 +129,7 @@ func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) // This method is generated by Databricks SDK Code Generator. func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsRequest) ([]CleanRoomInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[CleanRoomInfo, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -265,7 +265,7 @@ func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) * // This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[ProviderInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // ProviderInfoNameToMetastoreIdMap calls [ProvidersAPI.ListAll] and creates a map of results with [ProviderInfo].Name as key and [ProviderInfo].MetastoreId as value. @@ -327,7 +327,7 @@ func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest // This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListSharesAll(ctx context.Context, request ListSharesRequest) ([]ProviderShare, error) { iterator := a.ListShares(ctx, request) - return listing.ToSlice[ProviderShare](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // List shares by Provider. @@ -547,7 +547,7 @@ func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) // This method is generated by Databricks SDK Code Generator. func (a *RecipientsAPI) ListAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[RecipientInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // RecipientInfoNameToMetastoreIdMap calls [RecipientsAPI.ListAll] and creates a map of results with [RecipientInfo].Name as key and [RecipientInfo].MetastoreId as value. @@ -722,7 +722,7 @@ func (a *SharesAPI) List(ctx context.Context) *listing.PaginatingIterator[struct // This method is generated by Databricks SDK Code Generator. func (a *SharesAPI) ListAll(ctx context.Context) ([]ShareInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[ShareInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Get permissions. diff --git a/service/sql/api.go b/service/sql/api.go index c461b658a..98025b2a7 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -309,7 +309,7 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) getNextPage, getItems, getNextReq) - dedupedIterator := listing.NewDedupeIterator[Dashboard, string]( + dedupedIterator := listing.NewDedupeIterator( iterator, func(item Dashboard) string { return item.Id @@ -324,7 +324,7 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) // This method is generated by Databricks SDK Code Generator. func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[Dashboard, int](ctx, iterator, request.PageSize) + return listing.ToSliceN(ctx, iterator, request.PageSize) } @@ -672,7 +672,7 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *list getNextPage, getItems, getNextReq) - dedupedIterator := listing.NewDedupeIterator[Query, string]( + dedupedIterator := listing.NewDedupeIterator( iterator, func(item Query) string { return item.Id @@ -688,7 +688,7 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *list // This method is generated by Databricks SDK Code Generator. func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[Query, int](ctx, iterator, request.PageSize) + return listing.ToSliceN(ctx, iterator, request.PageSize) } @@ -829,7 +829,7 @@ func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequ // This method is generated by Databricks SDK Code Generator. func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN[QueryInfo, int](ctx, iterator, request.MaxResults) + return listing.ToSliceN(ctx, iterator, request.MaxResults) } @@ -1424,7 +1424,7 @@ func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) // This method is generated by Databricks SDK Code Generator. func (a *WarehousesAPI) ListAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[EndpointInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // EndpointInfoNameToIdMap calls [WarehousesAPI.ListAll] and creates a map of results with [EndpointInfo].Name as key and [EndpointInfo].Id as value. diff --git a/service/workspace/api.go b/service/workspace/api.go index cd70b2948..5f0a0437f 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -119,7 +119,7 @@ func (a *GitCredentialsAPI) List(ctx context.Context) *listing.PaginatingIterato // This method is generated by Databricks SDK Code Generator. func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error) { iterator := a.List(ctx) - return listing.ToSlice[CredentialInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // CredentialInfoGitProviderToCredentialIdMap calls [GitCredentialsAPI.ListAll] and creates a map of results with [CredentialInfo].GitProvider as key and [CredentialInfo].CredentialId as value. @@ -331,7 +331,7 @@ func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing. // This method is generated by Databricks SDK Code Generator. func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[RepoInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // RepoInfoPathToIdMap calls [ReposAPI.ListAll] and creates a map of results with [RepoInfo].Path as key and [RepoInfo].Id as value. @@ -576,7 +576,7 @@ func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *lis // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) { iterator := a.ListAcls(ctx, request) - return listing.ToSlice[AclItem](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // Lists ACLs. @@ -630,7 +630,7 @@ func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.PaginatingIterator // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { iterator := a.ListScopes(ctx) - return listing.ToSlice[SecretScope](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // List secret keys. @@ -677,7 +677,7 @@ func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) { iterator := a.ListSecrets(ctx, request) - return listing.ToSlice[SecretMetadata](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // List secret keys. @@ -912,7 +912,7 @@ func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) * // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice[ObjectInfo](ctx, iterator) + return listing.ToSlice(ctx, iterator) } // ObjectInfoPathToObjectIdMap calls [WorkspaceAPI.ListAll] and creates a map of results with [ObjectInfo].Path as key and [ObjectInfo].ObjectId as value. From 3e64cc79d8d492372385f66e2ab5895558b88451 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Mon, 23 Oct 2023 10:12:06 +0200 Subject: [PATCH 24/24] Revert "0.4.6 staticcheck" This reverts commit a84080d4a62a4de97f0d4e0e1af9f526252a922b. --- .codegen/api.go.tmpl | 6 ++--- Makefile | 2 +- service/billing/api.go | 4 ++-- service/catalog/api.go | 30 ++++++++++++------------- service/compute/api.go | 16 ++++++------- service/files/api.go | 2 +- service/iam/api.go | 14 ++++++------ service/iam/model.go | 6 ++--- service/jobs/api.go | 4 ++-- service/ml/api.go | 22 +++++++++--------- service/ml/model_registry_usage_test.go | 24 ++++++++++---------- service/oauth2/api.go | 8 +++---- service/pipelines/api.go | 4 ++-- service/serving/api.go | 2 +- service/settings/api.go | 8 +++---- service/sharing/api.go | 10 ++++----- service/sql/api.go | 12 +++++----- service/workspace/api.go | 12 +++++----- 18 files changed, 93 insertions(+), 93 deletions(-) diff --git a/.codegen/api.go.tmpl b/.codegen/api.go.tmpl index a43ca80f5..844b99730 100644 --- a/.codegen/api.go.tmpl +++ b/.codegen/api.go.tmpl @@ -205,7 +205,7 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} getItems, {{if .Pagination.MultiRequest}}getNextReq{{else}}nil{{end}}) {{ if .NeedsOffsetDedupe -}} - dedupedIterator := listing.NewDedupeIterator( + dedupedIterator := listing.NewDedupeIterator[{{ template "type" .Pagination.Entity }}, {{ template "type" .IdentifierField.Entity }}]( iterator, func(item {{ template "type" .Pagination.Entity }}) {{ template "type" .IdentifierField.Entity }} { return item{{ template "field-path" .IdFieldPath }} @@ -222,9 +222,9 @@ func (a *{{.Service.Name}}API) {{.PascalName}}(ctx context.Context{{if .Request} func (a *{{.Service.Name}}API) {{.PascalName}}All(ctx context.Context{{if .Request}}, request {{.Request.PascalName}}{{end}}) ([]{{ template "type" .Pagination.Entity }}, error) { iterator := a.{{.PascalName}}(ctx{{if .Request}}, request{{end}}) {{ if .Pagination.Limit -}} - return listing.ToSliceN(ctx, iterator, request.{{.Pagination.Limit.PascalName}}) + return listing.ToSliceN[{{ template "type" .Pagination.Entity }}, {{ template "type" .Pagination.Limit.Entity }}](ctx, iterator, request.{{.Pagination.Limit.PascalName}}) {{ else -}} - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[{{ template "type" .Pagination.Entity }}](ctx, iterator) {{- end }} } {{end}}{{if .NamedIdMap}} diff --git a/Makefile b/Makefile index 43b5e4a5d..57bf25ddd 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ fmt: lint: vendor @echo "✓ Linting source code with https://staticcheck.io/ ..." - @go run honnef.co/go/tools/cmd/staticcheck@v0.4.6 ./... + @go run honnef.co/go/tools/cmd/staticcheck@v0.4.0 ./... test: lint @echo "✓ Running tests ..." diff --git a/service/billing/api.go b/service/billing/api.go index 3d06edd36..cab8f4913 100755 --- a/service/billing/api.go +++ b/service/billing/api.go @@ -158,7 +158,7 @@ func (a *BudgetsAPI) List(ctx context.Context) *listing.PaginatingIterator[struc // This method is generated by Databricks SDK Code Generator. func (a *BudgetsAPI) ListAll(ctx context.Context) ([]BudgetWithStatus, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[BudgetWithStatus](ctx, iterator) } // BudgetWithStatusNameToBudgetIdMap calls [BudgetsAPI.ListAll] and creates a map of results with [BudgetWithStatus].Name as key and [BudgetWithStatus].BudgetId as value. @@ -390,7 +390,7 @@ func (a *LogDeliveryAPI) List(ctx context.Context, request ListLogDeliveryReques // This method is generated by Databricks SDK Code Generator. func (a *LogDeliveryAPI) ListAll(ctx context.Context, request ListLogDeliveryRequest) ([]LogDeliveryConfiguration, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[LogDeliveryConfiguration](ctx, iterator) } // LogDeliveryConfigurationConfigNameToConfigIdMap calls [LogDeliveryAPI.ListAll] and creates a map of results with [LogDeliveryConfiguration].ConfigName as key and [LogDeliveryConfiguration].ConfigId as value. diff --git a/service/catalog/api.go b/service/catalog/api.go index a9874b661..22e9a98fa 100755 --- a/service/catalog/api.go +++ b/service/catalog/api.go @@ -119,7 +119,7 @@ func (a *AccountMetastoreAssignmentsAPI) List(ctx context.Context, request ListA // This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoreAssignmentsAPI) ListAll(ctx context.Context, request ListAccountMetastoreAssignmentsRequest) ([]int64, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[int64](ctx, iterator) } // Get all workspaces assigned to a metastore. @@ -238,7 +238,7 @@ func (a *AccountMetastoresAPI) List(ctx context.Context) *listing.PaginatingIter // This method is generated by Databricks SDK Code Generator. func (a *AccountMetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[MetastoreInfo](ctx, iterator) } // Update a metastore. @@ -584,7 +584,7 @@ func (a *CatalogsAPI) List(ctx context.Context) *listing.PaginatingIterator[stru // This method is generated by Databricks SDK Code Generator. func (a *CatalogsAPI) ListAll(ctx context.Context) ([]CatalogInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[CatalogInfo](ctx, iterator) } // Update a catalog. @@ -707,7 +707,7 @@ func (a *ConnectionsAPI) List(ctx context.Context) *listing.PaginatingIterator[s // This method is generated by Databricks SDK Code Generator. func (a *ConnectionsAPI) ListAll(ctx context.Context) ([]ConnectionInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ConnectionInfo](ctx, iterator) } // ConnectionInfoNameToFullNameMap calls [ConnectionsAPI.ListAll] and creates a map of results with [ConnectionInfo].Name as key and [ConnectionInfo].FullName as value. @@ -895,7 +895,7 @@ func (a *ExternalLocationsAPI) List(ctx context.Context) *listing.PaginatingIter // This method is generated by Databricks SDK Code Generator. func (a *ExternalLocationsAPI) ListAll(ctx context.Context) ([]ExternalLocationInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ExternalLocationInfo](ctx, iterator) } // Update an external location. @@ -1048,7 +1048,7 @@ func (a *FunctionsAPI) List(ctx context.Context, request ListFunctionsRequest) * // This method is generated by Databricks SDK Code Generator. func (a *FunctionsAPI) ListAll(ctx context.Context, request ListFunctionsRequest) ([]FunctionInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[FunctionInfo](ctx, iterator) } // FunctionInfoNameToFullNameMap calls [FunctionsAPI.ListAll] and creates a map of results with [FunctionInfo].Name as key and [FunctionInfo].FullName as value. @@ -1307,7 +1307,7 @@ func (a *MetastoresAPI) List(ctx context.Context) *listing.PaginatingIterator[st // This method is generated by Databricks SDK Code Generator. func (a *MetastoresAPI) ListAll(ctx context.Context) ([]MetastoreInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[MetastoreInfo](ctx, iterator) } // MetastoreInfoNameToMetastoreIdMap calls [MetastoresAPI.ListAll] and creates a map of results with [MetastoreInfo].Name as key and [MetastoreInfo].MetastoreId as value. @@ -1580,7 +1580,7 @@ func (a *ModelVersionsAPI) List(ctx context.Context, request ListModelVersionsRe // This method is generated by Databricks SDK Code Generator. func (a *ModelVersionsAPI) ListAll(ctx context.Context, request ListModelVersionsRequest) ([]ModelVersionInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[ModelVersionInfo, int](ctx, iterator, request.MaxResults) } @@ -1830,7 +1830,7 @@ func (a *RegisteredModelsAPI) List(ctx context.Context, request ListRegisteredMo // This method is generated by Databricks SDK Code Generator. func (a *RegisteredModelsAPI) ListAll(ctx context.Context, request ListRegisteredModelsRequest) ([]RegisteredModelInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[RegisteredModelInfo, int](ctx, iterator, request.MaxResults) } @@ -2030,7 +2030,7 @@ func (a *SchemasAPI) List(ctx context.Context, request ListSchemasRequest) *list // This method is generated by Databricks SDK Code Generator. func (a *SchemasAPI) ListAll(ctx context.Context, request ListSchemasRequest) ([]SchemaInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[SchemaInfo](ctx, iterator) } // SchemaInfoNameToFullNameMap calls [SchemasAPI.ListAll] and creates a map of results with [SchemaInfo].Name as key and [SchemaInfo].FullName as value. @@ -2220,7 +2220,7 @@ func (a *StorageCredentialsAPI) List(ctx context.Context) *listing.PaginatingIte // This method is generated by Databricks SDK Code Generator. func (a *StorageCredentialsAPI) ListAll(ctx context.Context) ([]StorageCredentialInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[StorageCredentialInfo](ctx, iterator) } // StorageCredentialInfoNameToIdMap calls [StorageCredentialsAPI.ListAll] and creates a map of results with [StorageCredentialInfo].Name as key and [StorageCredentialInfo].Id as value. @@ -2361,7 +2361,7 @@ func (a *SystemSchemasAPI) List(ctx context.Context, request ListSystemSchemasRe // This method is generated by Databricks SDK Code Generator. func (a *SystemSchemasAPI) ListAll(ctx context.Context, request ListSystemSchemasRequest) ([]SystemSchemaInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[SystemSchemaInfo](ctx, iterator) } // List system schemas. @@ -2591,7 +2591,7 @@ func (a *TablesAPI) List(ctx context.Context, request ListTablesRequest) *listin // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListAll(ctx context.Context, request ListTablesRequest) ([]TableInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[TableInfo, int](ctx, iterator, request.MaxResults) } @@ -2704,7 +2704,7 @@ func (a *TablesAPI) ListSummaries(ctx context.Context, request ListSummariesRequ // This method is generated by Databricks SDK Code Generator. func (a *TablesAPI) ListSummariesAll(ctx context.Context, request ListSummariesRequest) ([]TableSummary, error) { iterator := a.ListSummaries(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[TableSummary, int](ctx, iterator, request.MaxResults) } @@ -2853,7 +2853,7 @@ func (a *VolumesAPI) List(ctx context.Context, request ListVolumesRequest) *list // This method is generated by Databricks SDK Code Generator. func (a *VolumesAPI) ListAll(ctx context.Context, request ListVolumesRequest) ([]VolumeInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[VolumeInfo](ctx, iterator) } // VolumeInfoNameToVolumeIdMap calls [VolumesAPI.ListAll] and creates a map of results with [VolumeInfo].Name as key and [VolumeInfo].VolumeId as value. diff --git a/service/compute/api.go b/service/compute/api.go index 5bb52a5d2..3170063e8 100755 --- a/service/compute/api.go +++ b/service/compute/api.go @@ -179,7 +179,7 @@ func (a *ClusterPoliciesAPI) List(ctx context.Context, request ListClusterPolici // This method is generated by Databricks SDK Code Generator. func (a *ClusterPoliciesAPI) ListAll(ctx context.Context, request ListClusterPoliciesRequest) ([]Policy, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Policy](ctx, iterator) } // PolicyNameToPolicyIdMap calls [ClusterPoliciesAPI.ListAll] and creates a map of results with [Policy].Name as key and [Policy].PolicyId as value. @@ -638,7 +638,7 @@ func (a *ClustersAPI) Events(ctx context.Context, request GetEvents) *listing.Pa // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) EventsAll(ctx context.Context, request GetEvents) ([]ClusterEvent, error) { iterator := a.Events(ctx, request) - return listing.ToSliceN(ctx, iterator, request.Limit) + return listing.ToSliceN[ClusterEvent, int64](ctx, iterator, request.Limit) } @@ -740,7 +740,7 @@ func (a *ClustersAPI) List(ctx context.Context, request ListClustersRequest) *li // This method is generated by Databricks SDK Code Generator. func (a *ClustersAPI) ListAll(ctx context.Context, request ListClustersRequest) ([]ClusterDetails, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ClusterDetails](ctx, iterator) } // ClusterDetailsClusterNameToClusterIdMap calls [ClustersAPI.ListAll] and creates a map of results with [ClusterDetails].ClusterName as key and [ClusterDetails].ClusterId as value. @@ -1578,7 +1578,7 @@ func (a *GlobalInitScriptsAPI) List(ctx context.Context) *listing.PaginatingIter // This method is generated by Databricks SDK Code Generator. func (a *GlobalInitScriptsAPI) ListAll(ctx context.Context) ([]GlobalInitScriptDetails, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[GlobalInitScriptDetails](ctx, iterator) } // GlobalInitScriptDetailsNameToScriptIdMap calls [GlobalInitScriptsAPI.ListAll] and creates a map of results with [GlobalInitScriptDetails].Name as key and [GlobalInitScriptDetails].ScriptId as value. @@ -1799,7 +1799,7 @@ func (a *InstancePoolsAPI) List(ctx context.Context) *listing.PaginatingIterator // This method is generated by Databricks SDK Code Generator. func (a *InstancePoolsAPI) ListAll(ctx context.Context) ([]InstancePoolAndStats, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[InstancePoolAndStats](ctx, iterator) } // InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap calls [InstancePoolsAPI.ListAll] and creates a map of results with [InstancePoolAndStats].InstancePoolName as key and [InstancePoolAndStats].InstancePoolId as value. @@ -1967,7 +1967,7 @@ func (a *InstanceProfilesAPI) List(ctx context.Context) *listing.PaginatingItera // This method is generated by Databricks SDK Code Generator. func (a *InstanceProfilesAPI) ListAll(ctx context.Context) ([]InstanceProfile, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[InstanceProfile](ctx, iterator) } // Remove the instance profile. @@ -2106,7 +2106,7 @@ func (a *LibrariesAPI) ClusterStatus(ctx context.Context, request ClusterStatusR // This method is generated by Databricks SDK Code Generator. func (a *LibrariesAPI) ClusterStatusAll(ctx context.Context, request ClusterStatusRequest) ([]LibraryFullStatus, error) { iterator := a.ClusterStatus(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[LibraryFullStatus](ctx, iterator) } // Get status. @@ -2240,6 +2240,6 @@ func (a *PolicyFamiliesAPI) List(ctx context.Context, request ListPolicyFamilies // This method is generated by Databricks SDK Code Generator. func (a *PolicyFamiliesAPI) ListAll(ctx context.Context, request ListPolicyFamiliesRequest) ([]PolicyFamily, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[PolicyFamily, int64](ctx, iterator, request.MaxResults) } diff --git a/service/files/api.go b/service/files/api.go index 0e394761b..6f4353001 100755 --- a/service/files/api.go +++ b/service/files/api.go @@ -177,7 +177,7 @@ func (a *DbfsAPI) List(ctx context.Context, request ListDbfsRequest) *listing.Pa // This method is generated by Databricks SDK Code Generator. func (a *DbfsAPI) ListAll(ctx context.Context, request ListDbfsRequest) ([]FileInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[FileInfo](ctx, iterator) } // List directory contents or file details. diff --git a/service/iam/api.go b/service/iam/api.go index 4fdf5379e..5c6b1d027 100755 --- a/service/iam/api.go +++ b/service/iam/api.go @@ -228,7 +228,7 @@ func (a *AccountGroupsAPI) List(ctx context.Context, request ListAccountGroupsRe // This method is generated by Databricks SDK Code Generator. func (a *AccountGroupsAPI) ListAll(ctx context.Context, request ListAccountGroupsRequest) ([]Group, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Group](ctx, iterator) } // GroupDisplayNameToIdMap calls [AccountGroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -401,7 +401,7 @@ func (a *AccountServicePrincipalsAPI) List(ctx context.Context, request ListAcco // This method is generated by Databricks SDK Code Generator. func (a *AccountServicePrincipalsAPI) ListAll(ctx context.Context, request ListAccountServicePrincipalsRequest) ([]ServicePrincipal, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ServicePrincipal](ctx, iterator) } // ServicePrincipalDisplayNameToIdMap calls [AccountServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -583,7 +583,7 @@ func (a *AccountUsersAPI) List(ctx context.Context, request ListAccountUsersRequ // This method is generated by Databricks SDK Code Generator. func (a *AccountUsersAPI) ListAll(ctx context.Context, request ListAccountUsersRequest) ([]User, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[User](ctx, iterator) } // UserUserNameToIdMap calls [AccountUsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -792,7 +792,7 @@ func (a *GroupsAPI) List(ctx context.Context, request ListGroupsRequest) *listin // This method is generated by Databricks SDK Code Generator. func (a *GroupsAPI) ListAll(ctx context.Context, request ListGroupsRequest) ([]Group, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Group](ctx, iterator) } // GroupDisplayNameToIdMap calls [GroupsAPI.ListAll] and creates a map of results with [Group].DisplayName as key and [Group].Id as value. @@ -1090,7 +1090,7 @@ func (a *ServicePrincipalsAPI) List(ctx context.Context, request ListServicePrin // This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalsAPI) ListAll(ctx context.Context, request ListServicePrincipalsRequest) ([]ServicePrincipal, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ServicePrincipal](ctx, iterator) } // ServicePrincipalDisplayNameToIdMap calls [ServicePrincipalsAPI.ListAll] and creates a map of results with [ServicePrincipal].DisplayName as key and [ServicePrincipal].Id as value. @@ -1287,7 +1287,7 @@ func (a *UsersAPI) List(ctx context.Context, request ListUsersRequest) *listing. // This method is generated by Databricks SDK Code Generator. func (a *UsersAPI) ListAll(ctx context.Context, request ListUsersRequest) ([]User, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[User](ctx, iterator) } // UserUserNameToIdMap calls [UsersAPI.ListAll] and creates a map of results with [User].UserName as key and [User].Id as value. @@ -1471,7 +1471,7 @@ func (a *WorkspaceAssignmentAPI) List(ctx context.Context, request ListWorkspace // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAssignmentAPI) ListAll(ctx context.Context, request ListWorkspaceAssignmentRequest) ([]PermissionAssignment, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[PermissionAssignment](ctx, iterator) } // Get permission assignments. diff --git a/service/iam/model.go b/service/iam/model.go index f13094f41..f08919356 100755 --- a/service/iam/model.go +++ b/service/iam/model.go @@ -229,7 +229,7 @@ type Group struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks group ID - Id string `json:"id,omitempty"` + Id string `json:"id,omitempty" url:"-"` Members []ComplexValue `json:"members,omitempty"` // Container for the group identifier. Workspace local versus account. @@ -1024,7 +1024,7 @@ type ServicePrincipal struct { Groups []ComplexValue `json:"groups,omitempty"` // Databricks service principal ID. - Id string `json:"id,omitempty" url:"-"` + Id string `json:"id,omitempty"` Roles []ComplexValue `json:"roles,omitempty"` @@ -1070,7 +1070,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 a2a1046ab..3fc54c127 100755 --- a/service/jobs/api.go +++ b/service/jobs/api.go @@ -359,7 +359,7 @@ func (a *JobsAPI) List(ctx context.Context, request ListJobsRequest) *listing.Pa // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListAll(ctx context.Context, request ListJobsRequest) ([]BaseJob, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.Limit) + return listing.ToSliceN[BaseJob, int](ctx, iterator, request.Limit) } @@ -452,7 +452,7 @@ func (a *JobsAPI) ListRuns(ctx context.Context, request ListRunsRequest) *listin // This method is generated by Databricks SDK Code Generator. func (a *JobsAPI) ListRunsAll(ctx context.Context, request ListRunsRequest) ([]BaseRun, error) { iterator := a.ListRuns(ctx, request) - return listing.ToSliceN(ctx, iterator, request.Limit) + return listing.ToSliceN[BaseRun, int](ctx, iterator, request.Limit) } diff --git a/service/ml/api.go b/service/ml/api.go index 71fd67333..a01153788 100755 --- a/service/ml/api.go +++ b/service/ml/api.go @@ -158,7 +158,7 @@ func (a *ExperimentsAPI) GetHistory(ctx context.Context, request GetHistoryReque // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) GetHistoryAll(ctx context.Context, request GetHistoryRequest) ([]Metric, error) { iterator := a.GetHistory(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[Metric, int](ctx, iterator, request.MaxResults) } @@ -246,7 +246,7 @@ func (a *ExperimentsAPI) ListArtifacts(ctx context.Context, request ListArtifact // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListArtifactsAll(ctx context.Context, request ListArtifactsRequest) ([]FileInfo, error) { iterator := a.ListArtifacts(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[FileInfo](ctx, iterator) } // List experiments. @@ -285,7 +285,7 @@ func (a *ExperimentsAPI) ListExperiments(ctx context.Context, request ListExperi // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) ListExperimentsAll(ctx context.Context, request ListExperimentsRequest) ([]Experiment, error) { iterator := a.ListExperiments(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[Experiment, int](ctx, iterator, request.MaxResults) } @@ -430,7 +430,7 @@ func (a *ExperimentsAPI) SearchExperiments(ctx context.Context, request SearchEx // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchExperimentsAll(ctx context.Context, request SearchExperiments) ([]Experiment, error) { iterator := a.SearchExperiments(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Experiment](ctx, iterator) } // Search for runs. @@ -473,7 +473,7 @@ func (a *ExperimentsAPI) SearchRuns(ctx context.Context, request SearchRuns) *li // This method is generated by Databricks SDK Code Generator. func (a *ExperimentsAPI) SearchRunsAll(ctx context.Context, request SearchRuns) ([]Run, error) { iterator := a.SearchRuns(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Run](ctx, iterator) } // Set a tag. @@ -680,7 +680,7 @@ func (a *ModelRegistryAPI) GetLatestVersions(ctx context.Context, request GetLat // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) GetLatestVersionsAll(ctx context.Context, request GetLatestVersionsRequest) ([]ModelVersion, error) { iterator := a.GetLatestVersions(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ModelVersion](ctx, iterator) } // Get model. @@ -780,7 +780,7 @@ func (a *ModelRegistryAPI) ListModels(ctx context.Context, request ListModelsReq // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListModelsAll(ctx context.Context, request ListModelsRequest) ([]Model, error) { iterator := a.ListModels(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[Model, int](ctx, iterator, request.MaxResults) } @@ -814,7 +814,7 @@ func (a *ModelRegistryAPI) ListTransitionRequests(ctx context.Context, request L // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListTransitionRequestsAll(ctx context.Context, request ListTransitionRequestsRequest) ([]Activity, error) { iterator := a.ListTransitionRequests(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[Activity](ctx, iterator) } // List registry webhooks. @@ -857,7 +857,7 @@ func (a *ModelRegistryAPI) ListWebhooks(ctx context.Context, request ListWebhook // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) ListWebhooksAll(ctx context.Context, request ListWebhooksRequest) ([]RegistryWebhook, error) { iterator := a.ListWebhooks(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[RegistryWebhook](ctx, iterator) } // Reject a transition request. @@ -910,7 +910,7 @@ func (a *ModelRegistryAPI) SearchModelVersions(ctx context.Context, request Sear // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelVersionsAll(ctx context.Context, request SearchModelVersionsRequest) ([]ModelVersion, error) { iterator := a.SearchModelVersions(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[ModelVersion, int](ctx, iterator, request.MaxResults) } @@ -950,7 +950,7 @@ func (a *ModelRegistryAPI) SearchModels(ctx context.Context, request SearchModel // This method is generated by Databricks SDK Code Generator. func (a *ModelRegistryAPI) SearchModelsAll(ctx context.Context, request SearchModelsRequest) ([]Model, error) { iterator := a.SearchModels(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[Model, int](ctx, iterator, request.MaxResults) } diff --git a/service/ml/model_registry_usage_test.go b/service/ml/model_registry_usage_test.go index 393ab2811..b5ccf9028 100755 --- a/service/ml/model_registry_usage_test.go +++ b/service/ml/model_registry_usage_test.go @@ -58,20 +58,20 @@ func ExampleModelRegistryAPI_CreateComment_modelVersionComments() { } -func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModel_models() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", model) + logger.Infof(ctx, "found %v", created) } @@ -92,24 +92,24 @@ func ExampleModelRegistryAPI_CreateModel_modelVersions() { } -func ExampleModelRegistryAPI_CreateModel_models() { +func ExampleModelRegistryAPI_CreateModel_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { panic(err) } - created, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ + model, err := w.ModelRegistry.CreateModel(ctx, ml.CreateModelRequest{ Name: fmt.Sprintf("sdk-%x", time.Now().UnixNano()), }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", model) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -124,18 +124,18 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { } logger.Infof(ctx, "found %v", model) - created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", created) + logger.Infof(ctx, "found %v", mv) } -func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { +func ExampleModelRegistryAPI_CreateModelVersion_modelVersions() { ctx := context.Background() w, err := databricks.NewWorkspaceClient() if err != nil { @@ -150,14 +150,14 @@ func ExampleModelRegistryAPI_CreateModelVersion_modelVersionComments() { } logger.Infof(ctx, "found %v", model) - mv, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ + created, err := w.ModelRegistry.CreateModelVersion(ctx, ml.CreateModelVersionRequest{ Name: model.RegisteredModel.Name, Source: "dbfs:/tmp", }) if err != nil { panic(err) } - logger.Infof(ctx, "found %v", mv) + logger.Infof(ctx, "found %v", created) } diff --git a/service/oauth2/api.go b/service/oauth2/api.go index 0e9a0e8ba..62cc1431b 100755 --- a/service/oauth2/api.go +++ b/service/oauth2/api.go @@ -117,7 +117,7 @@ func (a *CustomAppIntegrationAPI) List(ctx context.Context) *listing.PaginatingI // This method is generated by Databricks SDK Code Generator. func (a *CustomAppIntegrationAPI) ListAll(ctx context.Context) ([]GetCustomAppIntegrationOutput, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[GetCustomAppIntegrationOutput](ctx, iterator) } // Updates Custom OAuth App Integration. @@ -250,7 +250,7 @@ func (a *OAuthPublishedAppsAPI) List(ctx context.Context, request ListOAuthPubli // This method is generated by Databricks SDK Code Generator. func (a *OAuthPublishedAppsAPI) ListAll(ctx context.Context, request ListOAuthPublishedAppsRequest) ([]PublishedAppOutput, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.PageSize) + return listing.ToSliceN[PublishedAppOutput, int64](ctx, iterator, request.PageSize) } @@ -360,7 +360,7 @@ func (a *PublishedAppIntegrationAPI) List(ctx context.Context) *listing.Paginati // This method is generated by Databricks SDK Code Generator. func (a *PublishedAppIntegrationAPI) ListAll(ctx context.Context) ([]GetPublishedAppIntegrationOutput, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[GetPublishedAppIntegrationOutput](ctx, iterator) } // Updates Published OAuth App Integration. @@ -468,7 +468,7 @@ func (a *ServicePrincipalSecretsAPI) List(ctx context.Context, request ListServi // This method is generated by Databricks SDK Code Generator. func (a *ServicePrincipalSecretsAPI) ListAll(ctx context.Context, request ListServicePrincipalSecretsRequest) ([]SecretInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[SecretInfo](ctx, iterator) } // List service principal secrets. diff --git a/service/pipelines/api.go b/service/pipelines/api.go index 1162d81c4..b3f445388 100755 --- a/service/pipelines/api.go +++ b/service/pipelines/api.go @@ -285,7 +285,7 @@ func (a *PipelinesAPI) ListPipelineEvents(ctx context.Context, request ListPipel // This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelineEventsAll(ctx context.Context, request ListPipelineEventsRequest) ([]PipelineEvent, error) { iterator := a.ListPipelineEvents(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[PipelineEvent, int](ctx, iterator, request.MaxResults) } @@ -334,7 +334,7 @@ func (a *PipelinesAPI) ListPipelines(ctx context.Context, request ListPipelinesR // This method is generated by Databricks SDK Code Generator. func (a *PipelinesAPI) ListPipelinesAll(ctx context.Context, request ListPipelinesRequest) ([]PipelineStateInfo, error) { iterator := a.ListPipelines(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[PipelineStateInfo, int](ctx, iterator, request.MaxResults) } diff --git a/service/serving/api.go b/service/serving/api.go index 05d3ba9d6..7c62111e4 100755 --- a/service/serving/api.go +++ b/service/serving/api.go @@ -277,7 +277,7 @@ func (a *ServingEndpointsAPI) List(ctx context.Context) *listing.PaginatingItera // This method is generated by Databricks SDK Code Generator. func (a *ServingEndpointsAPI) ListAll(ctx context.Context) ([]ServingEndpoint, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ServingEndpoint](ctx, iterator) } // Retrieve the most recent log lines associated with a given serving endpoint's diff --git a/service/settings/api.go b/service/settings/api.go index 1cf8685e1..2987ce7b8 100755 --- a/service/settings/api.go +++ b/service/settings/api.go @@ -143,7 +143,7 @@ func (a *AccountIpAccessListsAPI) List(ctx context.Context) *listing.PaginatingI // This method is generated by Databricks SDK Code Generator. func (a *AccountIpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[IpAccessListInfo](ctx, iterator) } // IpAccessListInfoLabelToListIdMap calls [AccountIpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -460,7 +460,7 @@ func (a *IpAccessListsAPI) List(ctx context.Context) *listing.PaginatingIterator // This method is generated by Databricks SDK Code Generator. func (a *IpAccessListsAPI) ListAll(ctx context.Context) ([]IpAccessListInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[IpAccessListInfo](ctx, iterator) } // IpAccessListInfoLabelToListIdMap calls [IpAccessListsAPI.ListAll] and creates a map of results with [IpAccessListInfo].Label as key and [IpAccessListInfo].ListId as value. @@ -722,7 +722,7 @@ func (a *TokenManagementAPI) List(ctx context.Context, request ListTokenManageme // This method is generated by Databricks SDK Code Generator. func (a *TokenManagementAPI) ListAll(ctx context.Context, request ListTokenManagementRequest) ([]TokenInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[TokenInfo](ctx, iterator) } // TokenInfoCommentToTokenIdMap calls [TokenManagementAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. @@ -885,7 +885,7 @@ func (a *TokensAPI) List(ctx context.Context) *listing.PaginatingIterator[struct // This method is generated by Databricks SDK Code Generator. func (a *TokensAPI) ListAll(ctx context.Context) ([]TokenInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[TokenInfo](ctx, iterator) } // TokenInfoCommentToTokenIdMap calls [TokensAPI.ListAll] and creates a map of results with [TokenInfo].Comment as key and [TokenInfo].TokenId as value. diff --git a/service/sharing/api.go b/service/sharing/api.go index eb5169b7a..3cf721818 100755 --- a/service/sharing/api.go +++ b/service/sharing/api.go @@ -129,7 +129,7 @@ func (a *CleanRoomsAPI) List(ctx context.Context, request ListCleanRoomsRequest) // This method is generated by Databricks SDK Code Generator. func (a *CleanRoomsAPI) ListAll(ctx context.Context, request ListCleanRoomsRequest) ([]CleanRoomInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[CleanRoomInfo, int](ctx, iterator, request.MaxResults) } @@ -265,7 +265,7 @@ func (a *ProvidersAPI) List(ctx context.Context, request ListProvidersRequest) * // This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListAll(ctx context.Context, request ListProvidersRequest) ([]ProviderInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ProviderInfo](ctx, iterator) } // ProviderInfoNameToMetastoreIdMap calls [ProvidersAPI.ListAll] and creates a map of results with [ProviderInfo].Name as key and [ProviderInfo].MetastoreId as value. @@ -327,7 +327,7 @@ func (a *ProvidersAPI) ListShares(ctx context.Context, request ListSharesRequest // This method is generated by Databricks SDK Code Generator. func (a *ProvidersAPI) ListSharesAll(ctx context.Context, request ListSharesRequest) ([]ProviderShare, error) { iterator := a.ListShares(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ProviderShare](ctx, iterator) } // List shares by Provider. @@ -547,7 +547,7 @@ func (a *RecipientsAPI) List(ctx context.Context, request ListRecipientsRequest) // This method is generated by Databricks SDK Code Generator. func (a *RecipientsAPI) ListAll(ctx context.Context, request ListRecipientsRequest) ([]RecipientInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[RecipientInfo](ctx, iterator) } // RecipientInfoNameToMetastoreIdMap calls [RecipientsAPI.ListAll] and creates a map of results with [RecipientInfo].Name as key and [RecipientInfo].MetastoreId as value. @@ -722,7 +722,7 @@ func (a *SharesAPI) List(ctx context.Context) *listing.PaginatingIterator[struct // This method is generated by Databricks SDK Code Generator. func (a *SharesAPI) ListAll(ctx context.Context) ([]ShareInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ShareInfo](ctx, iterator) } // Get permissions. diff --git a/service/sql/api.go b/service/sql/api.go index 98025b2a7..c461b658a 100755 --- a/service/sql/api.go +++ b/service/sql/api.go @@ -309,7 +309,7 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) getNextPage, getItems, getNextReq) - dedupedIterator := listing.NewDedupeIterator( + dedupedIterator := listing.NewDedupeIterator[Dashboard, string]( iterator, func(item Dashboard) string { return item.Id @@ -324,7 +324,7 @@ func (a *DashboardsAPI) List(ctx context.Context, request ListDashboardsRequest) // This method is generated by Databricks SDK Code Generator. func (a *DashboardsAPI) ListAll(ctx context.Context, request ListDashboardsRequest) ([]Dashboard, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.PageSize) + return listing.ToSliceN[Dashboard, int](ctx, iterator, request.PageSize) } @@ -672,7 +672,7 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *list getNextPage, getItems, getNextReq) - dedupedIterator := listing.NewDedupeIterator( + dedupedIterator := listing.NewDedupeIterator[Query, string]( iterator, func(item Query) string { return item.Id @@ -688,7 +688,7 @@ func (a *QueriesAPI) List(ctx context.Context, request ListQueriesRequest) *list // This method is generated by Databricks SDK Code Generator. func (a *QueriesAPI) ListAll(ctx context.Context, request ListQueriesRequest) ([]Query, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.PageSize) + return listing.ToSliceN[Query, int](ctx, iterator, request.PageSize) } @@ -829,7 +829,7 @@ func (a *QueryHistoryAPI) List(ctx context.Context, request ListQueryHistoryRequ // This method is generated by Databricks SDK Code Generator. func (a *QueryHistoryAPI) ListAll(ctx context.Context, request ListQueryHistoryRequest) ([]QueryInfo, error) { iterator := a.List(ctx, request) - return listing.ToSliceN(ctx, iterator, request.MaxResults) + return listing.ToSliceN[QueryInfo, int](ctx, iterator, request.MaxResults) } @@ -1424,7 +1424,7 @@ func (a *WarehousesAPI) List(ctx context.Context, request ListWarehousesRequest) // This method is generated by Databricks SDK Code Generator. func (a *WarehousesAPI) ListAll(ctx context.Context, request ListWarehousesRequest) ([]EndpointInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[EndpointInfo](ctx, iterator) } // EndpointInfoNameToIdMap calls [WarehousesAPI.ListAll] and creates a map of results with [EndpointInfo].Name as key and [EndpointInfo].Id as value. diff --git a/service/workspace/api.go b/service/workspace/api.go index 5f0a0437f..cd70b2948 100755 --- a/service/workspace/api.go +++ b/service/workspace/api.go @@ -119,7 +119,7 @@ func (a *GitCredentialsAPI) List(ctx context.Context) *listing.PaginatingIterato // This method is generated by Databricks SDK Code Generator. func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error) { iterator := a.List(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[CredentialInfo](ctx, iterator) } // CredentialInfoGitProviderToCredentialIdMap calls [GitCredentialsAPI.ListAll] and creates a map of results with [CredentialInfo].GitProvider as key and [CredentialInfo].CredentialId as value. @@ -331,7 +331,7 @@ func (a *ReposAPI) List(ctx context.Context, request ListReposRequest) *listing. // This method is generated by Databricks SDK Code Generator. func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[RepoInfo](ctx, iterator) } // RepoInfoPathToIdMap calls [ReposAPI.ListAll] and creates a map of results with [RepoInfo].Path as key and [RepoInfo].Id as value. @@ -576,7 +576,7 @@ func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) *lis // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error) { iterator := a.ListAcls(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[AclItem](ctx, iterator) } // Lists ACLs. @@ -630,7 +630,7 @@ func (a *SecretsAPI) ListScopes(ctx context.Context) *listing.PaginatingIterator // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error) { iterator := a.ListScopes(ctx) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[SecretScope](ctx, iterator) } // List secret keys. @@ -677,7 +677,7 @@ func (a *SecretsAPI) ListSecrets(ctx context.Context, request ListSecretsRequest // This method is generated by Databricks SDK Code Generator. func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error) { iterator := a.ListSecrets(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[SecretMetadata](ctx, iterator) } // List secret keys. @@ -912,7 +912,7 @@ func (a *WorkspaceAPI) List(ctx context.Context, request ListWorkspaceRequest) * // This method is generated by Databricks SDK Code Generator. func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error) { iterator := a.List(ctx, request) - return listing.ToSlice(ctx, iterator) + return listing.ToSlice[ObjectInfo](ctx, iterator) } // ObjectInfoPathToObjectIdMap calls [WorkspaceAPI.ListAll] and creates a map of results with [ObjectInfo].Path as key and [ObjectInfo].ObjectId as value.