Skip to content

Commit

Permalink
(Breaking change) Moved long-running operations to AndWait methods (#…
Browse files Browse the repository at this point in the history
…35)

Any long-running operations do require now an explicit call to the method with an explicit `AndWait` suffix
  • Loading branch information
nfx committed Mar 25, 2024
1 parent 74fd107 commit fe2c0ae
Show file tree
Hide file tree
Showing 119 changed files with 2,893 additions and 2,699 deletions.
36 changes: 24 additions & 12 deletions .codegen/service.R.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,45 @@ NULL

{{range .Methods}}{{.Comment "#' " 80}}
#' @param client Required. Instance of DatabricksClient()
{{if .Request}}#'{{range .Request.Fields}}
#' @param {{.SnakeName}} {{if .Required}}Required. {{end}}{{with .Summary}}{{.}}{{else}}This field has no description yet.{{end}}{{end}}
{{end}}{{if .Pagination}}#'
#' @return `data.frame` with all of the response pages.
{{end}}#'
#' @rdname {{.Service.CamelName}}{{.PascalName}}
#' @export
{{- $hasRequiredFields := and .Request (gt (len .Request.RequiredFields) 0) }}
{{.Service.CamelName}}{{.PascalName}} <- function(client{{- if .Request}}{{range .Request.RequiredFields}}, {{.SnakeName}}{{end -}}
{{- range .Request.NonRequiredFields}}, {{.SnakeName}}=NULL{{end}}
{{- end}}) {
{{- template "method-serialize" .}}
{{template "method-call" .}}
}
{{end}}
{{- range .Methods}}{{if and .Wait (not .IsCrudRead)}}{{.Comment "#' " 80}}
#' @param client Required. Instance of DatabricksClient()
{{if .Request}}
{{if and .Wait (not .IsCrudRead)}}#'
#'
#' @description
#' This is a long-running operation, which blocks until {{.Service.TitleName}} on Databricks reach
#' {{range $i, $s := .Wait.Success}}{{if $i}} or {{end}}{{.Content}}{{end}} state with the timeout of {{.Wait.Timeout}} minutes, that you can change via `timeout` parameter.
#' By default, the state of Databricks {{.Service.TitleName}} is reported to console. You can change this behavior
#' by changing the `callback` parameter.
#' @param timeout Time to wait for the operation to complete in minutes.
#' @param callback Function to report the status of the operation. By default, it reports to console.
{{end}}
{{if .Request.RequiredFields}}#'
{{end}}#'{{range .Request.Fields}}
#'{{range .Request.Fields}}
#' @param {{.SnakeName}} {{if .Required}}Required. {{end}}{{with .Summary}}{{.}}{{else}}This field has no description yet.{{end}}{{end}}
{{end}}{{if .Pagination}}#'
#' @return `data.frame` with all of the response pages.
{{end}}#'
#' @rdname {{.Service.CamelName}}{{.PascalName}}
#' @rdname {{.Service.CamelName}}{{.PascalName}}AndWait
#' @export
{{- $hasRequiredFields := and .Request (gt (len .Request.RequiredFields) 0) }}
{{.Service.CamelName}}{{.PascalName}} <- function(client{{- if .Request}}{{range .Request.RequiredFields}}, {{.SnakeName}}{{end -}}
{{.Service.CamelName}}{{.PascalName}}AndWait <- function(client{{- if .Request}}{{range .Request.RequiredFields}}, {{.SnakeName}}{{end -}}
{{- range .Request.NonRequiredFields}}, {{.SnakeName}}=NULL{{end}}
{{- end}}{{if and .Wait (not .IsCrudRead)}}, timeout={{.Wait.Timeout}}, callback=cli_reporter{{end}}) {
{{- end}}, timeout={{.Wait.Timeout}}, callback=cli_reporter) {
{{- template "method-serialize" .}}
{{template "method-call" .}}
{{template "method-call-retried" .}}
}

{{end}}
{{end}}

{{- define "method-serialize" -}}
Expand All @@ -44,7 +57,6 @@ NULL

{{- define "method-call" -}}
{{if .Pagination -}}{{template "method-call-paginated" .}}
{{- else if and .Wait (not .IsCrudRead) -}}{{template "method-call-retried" .}}
{{- else}}{{template "method-call-default" .}}{{end}}
{{- end -}}

Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: build

on:
pull_request:
types: [opened, synchronize]
merge_group:
types: [checks_requested]
push:
# Always run on push to main. The build cache can only be reused
# if it was saved by a run from the repository's default branch.
# The run result will be identical to that from the merge queue
# because the commit is identical, yet we need to perform it to
# seed the build cache.
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
r-version: release
use-public-rspm: true

- name: Install dependencies
run: |
Rscript -e "if (!require(devtools)) install.packages('devtools', repos = 'https://cran.rstudio.com')"
Rscript -e "devtools::install_dev_deps('.')"
- name: Run tests
run: |
Rscript -e "devtools::test()"
22 changes: 22 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ export(clusterPoliciesSetPermissions)
export(clusterPoliciesUpdatePermissions)
export(clustersChangeOwner)
export(clustersCreate)
export(clustersCreateAndWait)
export(clustersDelete)
export(clustersDeleteAndWait)
export(clustersEdit)
export(clustersEditAndWait)
export(clustersEvents)
export(clustersGet)
export(clustersGetPermissionLevels)
Expand All @@ -52,18 +55,24 @@ export(clustersListZones)
export(clustersPermanentDelete)
export(clustersPin)
export(clustersResize)
export(clustersResizeAndWait)
export(clustersRestart)
export(clustersRestartAndWait)
export(clustersSetPermissions)
export(clustersSparkVersions)
export(clustersStart)
export(clustersStartAndWait)
export(clustersUnpin)
export(clustersUpdatePermissions)
export(commandExecutionCancel)
export(commandExecutionCancelAndWait)
export(commandExecutionCommandStatus)
export(commandExecutionContextStatus)
export(commandExecutionCreate)
export(commandExecutionCreateAndWait)
export(commandExecutionDestroy)
export(commandExecutionExecute)
export(commandExecutionExecuteAndWait)
export(connectionsCreate)
export(connectionsDelete)
export(connectionsGet)
Expand Down Expand Up @@ -189,6 +198,7 @@ export(ipAccessListsReplace)
export(ipAccessListsUpdate)
export(jobsCancelAllRuns)
export(jobsCancelRun)
export(jobsCancelRunAndWait)
export(jobsCreate)
export(jobsDelete)
export(jobsDeleteRun)
Expand All @@ -197,14 +207,18 @@ export(jobsGet)
export(jobsGetPermissionLevels)
export(jobsGetPermissions)
export(jobsGetRun)
export(jobsGetRunAndWait)
export(jobsGetRunOutput)
export(jobsList)
export(jobsListRuns)
export(jobsRepairRun)
export(jobsRepairRunAndWait)
export(jobsReset)
export(jobsRunNow)
export(jobsRunNowAndWait)
export(jobsSetPermissions)
export(jobsSubmit)
export(jobsSubmitAndWait)
export(jobsUpdate)
export(jobsUpdatePermissions)
export(lakehouseMonitorsCancelRefresh)
Expand Down Expand Up @@ -296,6 +310,7 @@ export(pipelinesListUpdates)
export(pipelinesSetPermissions)
export(pipelinesStartUpdate)
export(pipelinesStop)
export(pipelinesStopAndWait)
export(pipelinesUpdate)
export(pipelinesUpdatePermissions)
export(policyFamiliesGet)
Expand Down Expand Up @@ -368,6 +383,7 @@ export(servicePrincipalsPatch)
export(servicePrincipalsUpdate)
export(servingEndpointsBuildLogs)
export(servingEndpointsCreate)
export(servingEndpointsCreateAndWait)
export(servingEndpointsDelete)
export(servingEndpointsExportMetrics)
export(servingEndpointsGet)
Expand All @@ -380,6 +396,7 @@ export(servingEndpointsPut)
export(servingEndpointsQuery)
export(servingEndpointsSetPermissions)
export(servingEndpointsUpdateConfig)
export(servingEndpointsUpdateConfigAndWait)
export(servingEndpointsUpdatePermissions)
export(sharesCreate)
export(sharesDelete)
Expand Down Expand Up @@ -431,6 +448,7 @@ export(usersSetPermissions)
export(usersUpdate)
export(usersUpdatePermissions)
export(vectorSearchEndpointsCreateEndpoint)
export(vectorSearchEndpointsCreateEndpointAndWait)
export(vectorSearchEndpointsDeleteEndpoint)
export(vectorSearchEndpointsGetEndpoint)
export(vectorSearchEndpointsListEndpoints)
Expand All @@ -448,8 +466,10 @@ export(volumesList)
export(volumesRead)
export(volumesUpdate)
export(warehousesCreate)
export(warehousesCreateAndWait)
export(warehousesDelete)
export(warehousesEdit)
export(warehousesEditAndWait)
export(warehousesGet)
export(warehousesGetPermissionLevels)
export(warehousesGetPermissions)
Expand All @@ -458,7 +478,9 @@ export(warehousesList)
export(warehousesSetPermissions)
export(warehousesSetWorkspaceWarehouseConfig)
export(warehousesStart)
export(warehousesStartAndWait)
export(warehousesStop)
export(warehousesStopAndWait)
export(warehousesUpdatePermissions)
export(workspaceBindingsGet)
export(workspaceBindingsGetBindings)
Expand Down
13 changes: 2 additions & 11 deletions R/account_access_control_proxy.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 4 additions & 16 deletions R/alerts.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fe2c0ae

Please sign in to comment.