diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index ffd6f58dd9..303c785539 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -6f6b1371e640f2dfeba72d365ac566368656f6b6 \ No newline at end of file +0c86ea6dbd9a730c24ff0d4e509603e476955ac5 \ No newline at end of file diff --git a/go.mod b/go.mod index cb0d35a5ba..e01145f07e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/databricks/terraform-provider-databricks go 1.22 require ( - github.com/databricks/databricks-sdk-go v0.47.0 + github.com/databricks/databricks-sdk-go v0.48.0 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/hcl v1.0.0 diff --git a/go.sum b/go.sum index 8ff73d7ad5..dfd13d335a 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,8 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= -github.com/databricks/databricks-sdk-go v0.47.0 h1:eE7dN9axviL8+s10jnQAayOYDaR+Mfu7E9COGjO4lrQ= -github.com/databricks/databricks-sdk-go v0.47.0/go.mod h1:ds+zbv5mlQG7nFEU5ojLtgN/u0/9YzZmKQES/CfedzU= +github.com/databricks/databricks-sdk-go v0.48.0 h1:46KtsnRo+FGhC3izUXbpL0PXBNomvsdignYDhJZlm9s= +github.com/databricks/databricks-sdk-go v0.48.0/go.mod h1:ds+zbv5mlQG7nFEU5ojLtgN/u0/9YzZmKQES/CfedzU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/internal/service/apps_tf/model.go b/internal/service/apps_tf/model.go index 74406307a5..41a6990157 100755 --- a/internal/service/apps_tf/model.go +++ b/internal/service/apps_tf/model.go @@ -25,6 +25,10 @@ type App struct { CreateTime types.String `tfsdk:"create_time" tf:"optional"` // The email of the user that created the app. Creator types.String `tfsdk:"creator" tf:"optional"` + // The default workspace file system path of the source code from which app + // deployment are created. This field tracks the workspace source code path + // of the last active deployment. + DefaultSourceCodePath types.String `tfsdk:"default_source_code_path" tf:"optional"` // The description of the app. Description types.String `tfsdk:"description" tf:"optional"` // The name of the app. The name must contain only lowercase alphanumeric @@ -32,6 +36,8 @@ type App struct { Name types.String `tfsdk:"name" tf:""` // The pending deployment of the app. PendingDeployment *AppDeployment `tfsdk:"pending_deployment" tf:"optional"` + // Resources for the app. + Resources []AppResource `tfsdk:"resources" tf:"optional"` ServicePrincipalId types.Int64 `tfsdk:"service_principal_id" tf:"optional"` @@ -134,6 +140,55 @@ type AppPermissionsRequest struct { AppName types.String `tfsdk:"-"` } +type AppResource struct { + // Description of the App Resource. + Description types.String `tfsdk:"description" tf:"optional"` + + Job *AppResourceJob `tfsdk:"job" tf:"optional"` + // Name of the App Resource. + Name types.String `tfsdk:"name" tf:""` + + Secret *AppResourceSecret `tfsdk:"secret" tf:"optional"` + + ServingEndpoint *AppResourceServingEndpoint `tfsdk:"serving_endpoint" tf:"optional"` + + SqlWarehouse *AppResourceSqlWarehouse `tfsdk:"sql_warehouse" tf:"optional"` +} + +type AppResourceJob struct { + // Id of the job to grant permission on. + Id types.String `tfsdk:"id" tf:""` + // Permissions to grant on the Job. Supported permissions are: "CAN_MANAGE", + // "IS_OWNER", "CAN_MANAGE_RUN", "CAN_VIEW". + Permission types.String `tfsdk:"permission" tf:""` +} + +type AppResourceSecret struct { + // Key of the secret to grant permission on. + Key types.String `tfsdk:"key" tf:""` + // Permission to grant on the secret scope. For secrets, only one permission + // is allowed. Permission must be one of: "READ", "WRITE", "MANAGE". + Permission types.String `tfsdk:"permission" tf:""` + // Scope of the secret to grant permission on. + Scope types.String `tfsdk:"scope" tf:""` +} + +type AppResourceServingEndpoint struct { + // Name of the serving endpoint to grant permission on. + Name types.String `tfsdk:"name" tf:""` + // Permission to grant on the serving endpoint. Supported permissions are: + // "CAN_MANAGE", "CAN_QUERY", "CAN_VIEW". + Permission types.String `tfsdk:"permission" tf:""` +} + +type AppResourceSqlWarehouse struct { + // Id of the SQL warehouse to grant permission on. + Id types.String `tfsdk:"id" tf:""` + // Permission to grant on the SQL warehouse. Supported permissions are: + // "CAN_MANAGE", "CAN_USE", "IS_OWNER". + Permission types.String `tfsdk:"permission" tf:""` +} + type ApplicationStatus struct { // Application status message Message types.String `tfsdk:"message" tf:"optional"` @@ -171,6 +226,8 @@ type CreateAppRequest struct { // The name of the app. The name must contain only lowercase alphanumeric // characters and hyphens. It must be unique within the workspace. Name types.String `tfsdk:"name" tf:""` + // Resources for the app. + Resources []AppResource `tfsdk:"resources" tf:"optional"` } // Delete an app @@ -259,4 +316,6 @@ type UpdateAppRequest struct { // The name of the app. The name must contain only lowercase alphanumeric // characters and hyphens. It must be unique within the workspace. Name types.String `tfsdk:"name" tf:""` + // Resources for the app. + Resources []AppResource `tfsdk:"resources" tf:"optional"` } diff --git a/internal/service/catalog_tf/model.go b/internal/service/catalog_tf/model.go index 78848824f1..358885d57d 100755 --- a/internal/service/catalog_tf/model.go +++ b/internal/service/catalog_tf/model.go @@ -1062,9 +1062,8 @@ type GenerateTemporaryTableCredentialResponse struct { // Azure temporary credentials for API authentication. Read more at // https://docs.microsoft.com/en-us/rest/api/storageservices/create-user-delegation-sas AzureUserDelegationSas *AzureUserDelegationSas `tfsdk:"azure_user_delegation_sas" tf:"optional"` - // Server time when the credential will expire, in unix epoch milliseconds - // since January 1, 1970 at 00:00:00 UTC. The API client is advised to cache - // the credential given this expiration time. + // Server time when the credential will expire, in epoch milliseconds. The + // API client is advised to cache the credential given this expiration time. ExpirationTime types.Int64 `tfsdk:"expiration_time" tf:"optional"` // GCP temporary credentials for API authentication. Read more at // https://developers.google.com/identity/protocols/oauth2/service-account diff --git a/internal/service/dashboards_tf/model.go b/internal/service/dashboards_tf/model.go index fcc9f0adf6..2fcdbdc14c 100755 --- a/internal/service/dashboards_tf/model.go +++ b/internal/service/dashboards_tf/model.go @@ -23,7 +23,12 @@ type CreateDashboardRequest struct { // Dashboards responses. ParentPath types.String `tfsdk:"parent_path" tf:"optional"` // The contents of the dashboard in serialized string form. This field is - // excluded in List Dashboards responses. + // excluded in List Dashboards responses. Use the [get dashboard API] to + // retrieve an example response, which includes the `serialized_dashboard` + // field. This field provides the structure of the JSON string that + // represents the dashboard's layout and components. + // + // [get dashboard API]: https://docs.databricks.com/api/workspace/lakeview/get SerializedDashboard types.String `tfsdk:"serialized_dashboard" tf:"optional"` // The warehouse ID used to run the dashboard. WarehouseId types.String `tfsdk:"warehouse_id" tf:"optional"` @@ -81,11 +86,17 @@ type Dashboard struct { // leading slash and no trailing slash. This field is excluded in List // Dashboards responses. ParentPath types.String `tfsdk:"parent_path" tf:"optional"` - // The workspace path of the dashboard asset, including the file name. This + // The workspace path of the dashboard asset, including the file name. + // Exported dashboards always have the file extension `.lvdash.json`. This // field is excluded in List Dashboards responses. Path types.String `tfsdk:"path" tf:"optional"` // The contents of the dashboard in serialized string form. This field is - // excluded in List Dashboards responses. + // excluded in List Dashboards responses. Use the [get dashboard API] to + // retrieve an example response, which includes the `serialized_dashboard` + // field. This field provides the structure of the JSON string that + // represents the dashboard's layout and components. + // + // [get dashboard API]: https://docs.databricks.com/api/workspace/lakeview/get SerializedDashboard types.String `tfsdk:"serialized_dashboard" tf:"optional"` // The timestamp of when the dashboard was last updated by the user. This // field is excluded in List Dashboards responses. @@ -213,9 +224,10 @@ type GenieMessage struct { // Genie space ID SpaceId types.String `tfsdk:"space_id" tf:""` // MesssageStatus. The possible values are: * `FETCHING_METADATA`: Fetching - // metadata from the data sources. * `ASKING_AI`: Waiting for the LLM to - // respond to the users question. * `EXECUTING_QUERY`: Executing AI provided - // SQL query. Get the SQL query result by calling + // metadata from the data sources. * `FILTERING_CONTEXT`: Running smart + // context step to determine relevant context. * `ASKING_AI`: Waiting for + // the LLM to respond to the users question. * `EXECUTING_QUERY`: Executing + // AI provided SQL query. Get the SQL query result by calling // [getMessageQueryResult](:method:genie/getMessageQueryResult) API. // **Important: The message status will stay in the `EXECUTING_QUERY` until // a client calls @@ -510,7 +522,12 @@ type UpdateDashboardRequest struct { // field is excluded in List Dashboards responses. Etag types.String `tfsdk:"etag" tf:"optional"` // The contents of the dashboard in serialized string form. This field is - // excluded in List Dashboards responses. + // excluded in List Dashboards responses. Use the [get dashboard API] to + // retrieve an example response, which includes the `serialized_dashboard` + // field. This field provides the structure of the JSON string that + // represents the dashboard's layout and components. + // + // [get dashboard API]: https://docs.databricks.com/api/workspace/lakeview/get SerializedDashboard types.String `tfsdk:"serialized_dashboard" tf:"optional"` // The warehouse ID used to run the dashboard. WarehouseId types.String `tfsdk:"warehouse_id" tf:"optional"` diff --git a/internal/service/jobs_tf/model.go b/internal/service/jobs_tf/model.go index 457ea2bb4a..2699dc2286 100755 --- a/internal/service/jobs_tf/model.go +++ b/internal/service/jobs_tf/model.go @@ -735,7 +735,8 @@ type JobDeployment struct { type JobEmailNotifications struct { // If true, do not send email to recipients specified in `on_failure` if the - // run is skipped. + // run is skipped. This field is `deprecated`. Please use the + // `notification_settings.no_alert_for_skipped_runs` field. NoAlertForSkippedRuns types.Bool `tfsdk:"no_alert_for_skipped_runs" tf:"optional"` // A list of email addresses to be notified when the duration of a run // exceeds the threshold specified for the `RUN_DURATION_SECONDS` metric in @@ -1274,7 +1275,7 @@ type RepairRun struct { // [Task parameter variables]: https://docs.databricks.com/jobs.html#parameter-variables // [dbutils.widgets.get]: https://docs.databricks.com/dev-tools/databricks-utils.html NotebookParams map[string]types.String `tfsdk:"notebook_params" tf:"optional"` - + // Controls whether the pipeline should perform a full refresh PipelineParams *PipelineParams `tfsdk:"pipeline_params" tf:"optional"` PythonNamedParams map[string]types.String `tfsdk:"python_named_params" tf:"optional"` @@ -1630,7 +1631,7 @@ type RunJobTask struct { // [Task parameter variables]: https://docs.databricks.com/jobs.html#parameter-variables // [dbutils.widgets.get]: https://docs.databricks.com/dev-tools/databricks-utils.html NotebookParams map[string]types.String `tfsdk:"notebook_params" tf:"optional"` - + // Controls whether the pipeline should perform a full refresh PipelineParams *PipelineParams `tfsdk:"pipeline_params" tf:"optional"` PythonNamedParams map[string]types.String `tfsdk:"python_named_params" tf:"optional"` @@ -1733,7 +1734,7 @@ type RunNow struct { // [Task parameter variables]: https://docs.databricks.com/jobs.html#parameter-variables // [dbutils.widgets.get]: https://docs.databricks.com/dev-tools/databricks-utils.html NotebookParams map[string]types.String `tfsdk:"notebook_params" tf:"optional"` - + // Controls whether the pipeline should perform a full refresh PipelineParams *PipelineParams `tfsdk:"pipeline_params" tf:"optional"` PythonNamedParams map[string]types.String `tfsdk:"python_named_params" tf:"optional"` @@ -1867,7 +1868,7 @@ type RunParameters struct { // [Task parameter variables]: https://docs.databricks.com/jobs.html#parameter-variables // [dbutils.widgets.get]: https://docs.databricks.com/dev-tools/databricks-utils.html NotebookParams map[string]types.String `tfsdk:"notebook_params" tf:"optional"` - + // Controls whether the pipeline should perform a full refresh PipelineParams *PipelineParams `tfsdk:"pipeline_params" tf:"optional"` PythonNamedParams map[string]types.String `tfsdk:"python_named_params" tf:"optional"` @@ -2613,7 +2614,8 @@ type TaskDependency struct { type TaskEmailNotifications struct { // If true, do not send email to recipients specified in `on_failure` if the - // run is skipped. + // run is skipped. This field is `deprecated`. Please use the + // `notification_settings.no_alert_for_skipped_runs` field. NoAlertForSkippedRuns types.Bool `tfsdk:"no_alert_for_skipped_runs" tf:"optional"` // A list of email addresses to be notified when the duration of a run // exceeds the threshold specified for the `RUN_DURATION_SECONDS` metric in @@ -2662,8 +2664,9 @@ type TaskNotificationSettings struct { type TerminationDetails struct { // The code indicates why the run was terminated. Additional codes might be // introduced in future releases. * `SUCCESS`: The run was completed - // successfully. * `CANCELED`: The run was canceled during execution by the - // Databricks platform; for example, if the maximum run duration was + // successfully. * `USER_CANCELED`: The run was successfully canceled during + // execution by a user. * `CANCELED`: The run was canceled during execution + // by the Databricks platform; for example, if the maximum run duration was // exceeded. * `SKIPPED`: Run was never executed, for example, if the // upstream task run failed, the dependency type condition was not met, or // there were no material tasks to execute. * `INTERNAL_ERROR`: The run diff --git a/internal/service/pipelines_tf/model.go b/internal/service/pipelines_tf/model.go index b6abbbb71c..1740d0ee0b 100755 --- a/internal/service/pipelines_tf/model.go +++ b/internal/service/pipelines_tf/model.go @@ -60,6 +60,10 @@ type CreatePipeline struct { Notifications []Notifications `tfsdk:"notifications" tf:"optional"` // Whether Photon is enabled for this pipeline. Photon types.Bool `tfsdk:"photon" tf:"optional"` + // The default schema (database) where tables are read from or published to. + // The presence of this field implies that the pipeline is in direct + // publishing mode. + Schema types.String `tfsdk:"schema" tf:"optional"` // Whether serverless compute is enabled for this pipeline. Serverless types.Bool `tfsdk:"serverless" tf:"optional"` // DBFS root directory for storing checkpoints and tables. @@ -150,6 +154,10 @@ type EditPipeline struct { Photon types.Bool `tfsdk:"photon" tf:"optional"` // Unique identifier for this pipeline. PipelineId types.String `tfsdk:"pipeline_id" tf:"optional"` + // The default schema (database) where tables are read from or published to. + // The presence of this field implies that the pipeline is in direct + // publishing mode. + Schema types.String `tfsdk:"schema" tf:"optional"` // Whether serverless compute is enabled for this pipeline. Serverless types.Bool `tfsdk:"serverless" tf:"optional"` // DBFS root directory for storing checkpoints and tables. @@ -687,6 +695,10 @@ type PipelineSpec struct { Notifications []Notifications `tfsdk:"notifications" tf:"optional"` // Whether Photon is enabled for this pipeline. Photon types.Bool `tfsdk:"photon" tf:"optional"` + // The default schema (database) where tables are read from or published to. + // The presence of this field implies that the pipeline is in direct + // publishing mode. + Schema types.String `tfsdk:"schema" tf:"optional"` // Whether serverless compute is enabled for this pipeline. Serverless types.Bool `tfsdk:"serverless" tf:"optional"` // DBFS root directory for storing checkpoints and tables. diff --git a/internal/service/sql_tf/model.go b/internal/service/sql_tf/model.go index cbee45561b..e912363c30 100755 --- a/internal/service/sql_tf/model.go +++ b/internal/service/sql_tf/model.go @@ -194,6 +194,8 @@ type CancelExecutionRequest struct { type CancelExecutionResponse struct { } +// Configures the channel name and DBSQL version of the warehouse. +// CHANNEL_NAME_CUSTOM should be chosen only when `dbsql_version` is specified. type Channel struct { DbsqlVersion types.String `tfsdk:"dbsql_version" tf:"optional"` @@ -347,7 +349,9 @@ type CreateWarehouseRequest struct { // The amount of time in minutes that a SQL warehouse must be idle (i.e., no // RUNNING queries) before it is automatically stopped. // - // Supported values: - Must be == 0 or >= 10 mins - 0 indicates no autostop. + // Supported values: - Must be >= 0 mins for serverless warehouses - Must be + // == 0 or >= 10 mins for non-serverless warehouses - 0 indicates no + // autostop. // // Defaults to 120 mins AutoStopMins types.Int64 `tfsdk:"auto_stop_mins" tf:"optional"` diff --git a/internal/service/workspace_tf/model.go b/internal/service/workspace_tf/model.go index d11553b3a0..fe451acf89 100755 --- a/internal/service/workspace_tf/model.go +++ b/internal/service/workspace_tf/model.go @@ -29,11 +29,11 @@ type AzureKeyVaultSecretScopeMetadata struct { ResourceId types.String `tfsdk:"resource_id" tf:""` } -type CreateCredentials struct { +type CreateCredentialsRequest struct { // Git provider. This field is case-insensitive. The available Git providers - // are gitHub, bitbucketCloud, gitLab, azureDevOpsServices, - // gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and - // awsCodeCommit. + // are `gitHub`, `bitbucketCloud`, `gitLab`, `azureDevOpsServices`, + // `gitHubEnterprise`, `bitbucketServer`, `gitLabEnterpriseEdition` and + // `awsCodeCommit`. GitProvider types.String `tfsdk:"git_provider" tf:""` // The username or email provided with your Git provider account, depending // on which provider you are using. For GitHub, GitHub Enterprise Server, or @@ -45,8 +45,7 @@ type CreateCredentials struct { GitUsername types.String `tfsdk:"git_username" tf:"optional"` // The personal access token used to authenticate to the corresponding Git // provider. For certain providers, support may exist for other types of - // scoped access tokens. [Learn more]. The personal access token used to - // authenticate to the corresponding Git + // scoped access tokens. [Learn more]. // // [Learn more]: https://docs.databricks.com/repos/get-access-tokens-from-git-provider.html PersonalAccessToken types.String `tfsdk:"personal_access_token" tf:"optional"` @@ -54,31 +53,23 @@ type CreateCredentials struct { type CreateCredentialsResponse struct { // ID of the credential object in the workspace. - CredentialId types.Int64 `tfsdk:"credential_id" tf:"optional"` - // Git provider. This field is case-insensitive. The available Git providers - // are gitHub, bitbucketCloud, gitLab, azureDevOpsServices, - // gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and - // awsCodeCommit. - GitProvider types.String `tfsdk:"git_provider" tf:"optional"` - // The username or email provided with your Git provider account, depending - // on which provider you are using. For GitHub, GitHub Enterprise Server, or - // Azure DevOps Services, either email or username may be used. For GitLab, - // GitLab Enterprise Edition, email must be used. For AWS CodeCommit, - // BitBucket or BitBucket Server, username must be used. For all other - // providers please see your provider's Personal Access Token authentication - // documentation to see what is supported. + CredentialId types.Int64 `tfsdk:"credential_id" tf:""` + // The Git provider associated with the credential. + GitProvider types.String `tfsdk:"git_provider" tf:""` + // The username or email provided with your Git provider account and + // associated with the credential. GitUsername types.String `tfsdk:"git_username" tf:"optional"` } -type CreateRepo struct { +type CreateRepoRequest struct { // Desired path for the repo in the workspace. Almost any path in the - // workspace can be chosen. If repo is created in /Repos, path must be in - // the format /Repos/{folder}/{repo-name}. + // workspace can be chosen. If repo is created in `/Repos`, path must be in + // the format `/Repos/{folder}/{repo-name}`. Path types.String `tfsdk:"path" tf:"optional"` // Git provider. This field is case-insensitive. The available Git providers - // are gitHub, bitbucketCloud, gitLab, azureDevOpsServices, - // gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and - // awsCodeCommit. + // are `gitHub`, `bitbucketCloud`, `gitLab`, `azureDevOpsServices`, + // `gitHubEnterprise`, `bitbucketServer`, `gitLabEnterpriseEdition` and + // `awsCodeCommit`. Provider types.String `tfsdk:"provider" tf:""` // If specified, the repo will be created with sparse checkout enabled. You // cannot enable/disable sparse checkout after the repo is created. @@ -87,6 +78,24 @@ type CreateRepo struct { Url types.String `tfsdk:"url" tf:""` } +type CreateRepoResponse struct { + // Branch that the Git folder (repo) is checked out to. + Branch types.String `tfsdk:"branch" tf:"optional"` + // SHA-1 hash representing the commit ID of the current HEAD of the Git + // folder (repo). + HeadCommitId types.String `tfsdk:"head_commit_id" tf:"optional"` + // ID of the Git folder (repo) object in the workspace. + Id types.Int64 `tfsdk:"id" tf:"optional"` + // Path of the Git folder (repo) in the workspace. + Path types.String `tfsdk:"path" tf:"optional"` + // Git provider of the linked Git repository. + Provider types.String `tfsdk:"provider" tf:"optional"` + // Sparse checkout settings for the Git folder (repo). + SparseCheckout *SparseCheckout `tfsdk:"sparse_checkout" tf:"optional"` + // URL of the linked Git repository. + Url types.String `tfsdk:"url" tf:"optional"` +} + type CreateScope struct { // The metadata for the secret scope if the type is `AZURE_KEYVAULT` BackendAzureKeyvault *AzureKeyVaultSecretScopeMetadata `tfsdk:"backend_azure_keyvault" tf:"optional"` @@ -105,19 +114,11 @@ type CreateScopeResponse struct { type CredentialInfo struct { // ID of the credential object in the workspace. - CredentialId types.Int64 `tfsdk:"credential_id" tf:"optional"` - // Git provider. This field is case-insensitive. The available Git providers - // are gitHub, gitHubOAuth, bitbucketCloud, gitLab, azureDevOpsServices, - // gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and - // awsCodeCommit. + CredentialId types.Int64 `tfsdk:"credential_id" tf:""` + // The Git provider associated with the credential. GitProvider types.String `tfsdk:"git_provider" tf:"optional"` - // The username or email provided with your Git provider account, depending - // on which provider you are using. For GitHub, GitHub Enterprise Server, or - // Azure DevOps Services, either email or username may be used. For GitLab, - // GitLab Enterprise Edition, email must be used. For AWS CodeCommit, - // BitBucket or BitBucket Server, username must be used. For all other - // providers please see your provider's Personal Access Token authentication - // documentation to see what is supported. + // The username or email provided with your Git provider account and + // associated with the credential. GitUsername types.String `tfsdk:"git_username" tf:"optional"` } @@ -142,17 +143,23 @@ type DeleteAclResponse struct { } // Delete a credential -type DeleteGitCredentialRequest struct { +type DeleteCredentialsRequest struct { // The ID for the corresponding credential to access. CredentialId types.Int64 `tfsdk:"-"` } +type DeleteCredentialsResponse struct { +} + // Delete a repo type DeleteRepoRequest struct { - // The ID for the corresponding repo to access. + // ID of the Git folder (repo) object in the workspace. RepoId types.Int64 `tfsdk:"-"` } +type DeleteRepoResponse struct { +} + type DeleteResponse struct { } @@ -212,16 +219,22 @@ type GetAclRequest struct { Scope types.String `tfsdk:"-"` } -type GetCredentialsResponse struct { - Credentials []CredentialInfo `tfsdk:"credentials" tf:"optional"` -} - // Get a credential entry -type GetGitCredentialRequest struct { +type GetCredentialsRequest struct { // The ID for the corresponding credential to access. CredentialId types.Int64 `tfsdk:"-"` } +type GetCredentialsResponse struct { + // ID of the credential object in the workspace. + CredentialId types.Int64 `tfsdk:"credential_id" tf:""` + // The Git provider associated with the credential. + GitProvider types.String `tfsdk:"git_provider" tf:"optional"` + // The username or email provided with your Git provider account and + // associated with the credential. + GitUsername types.String `tfsdk:"git_username" tf:"optional"` +} + // Get repo permission levels type GetRepoPermissionLevelsRequest struct { // The repo for which to get or manage permissions. @@ -241,10 +254,27 @@ type GetRepoPermissionsRequest struct { // Get a repo type GetRepoRequest struct { - // The ID for the corresponding repo to access. + // ID of the Git folder (repo) object in the workspace. RepoId types.Int64 `tfsdk:"-"` } +type GetRepoResponse struct { + // Branch that the local version of the repo is checked out to. + Branch types.String `tfsdk:"branch" tf:"optional"` + // SHA-1 hash representing the commit ID of the current HEAD of the repo. + HeadCommitId types.String `tfsdk:"head_commit_id" tf:"optional"` + // ID of the Git folder (repo) object in the workspace. + Id types.Int64 `tfsdk:"id" tf:"optional"` + // Path of the Git folder (repo) in the workspace. + Path types.String `tfsdk:"path" tf:"optional"` + // Git provider of the linked Git repository. + Provider types.String `tfsdk:"provider" tf:"optional"` + // Sparse checkout settings for the Git folder (repo). + SparseCheckout *SparseCheckout `tfsdk:"sparse_checkout" tf:"optional"` + // URL of the linked Git repository. + Url types.String `tfsdk:"url" tf:"optional"` +} + // Get a secret type GetSecretRequest struct { // The key to fetch secret for. @@ -334,6 +364,11 @@ type ListAclsResponse struct { Items []AclItem `tfsdk:"items" tf:"optional"` } +type ListCredentialsResponse struct { + // List of credentials. + Credentials []CredentialInfo `tfsdk:"credentials" tf:"optional"` +} + // Get repos type ListReposRequest struct { // Token used to get the next page of results. If not specified, returns the @@ -341,15 +376,16 @@ type ListReposRequest struct { // results. NextPageToken types.String `tfsdk:"-"` // Filters repos that have paths starting with the given path prefix. If not - // provided repos from /Repos will be served. + // provided or when provided an effectively empty prefix (`/` or + // `/Workspace`) Git folders (repos) from `/Workspace/Repos` will be served. PathPrefix types.String `tfsdk:"-"` } type ListReposResponse struct { - // Token that can be specified as a query parameter to the GET /repos + // Token that can be specified as a query parameter to the `GET /repos` // endpoint to retrieve the next page of results. NextPageToken types.String `tfsdk:"next_page_token" tf:"optional"` - + // List of Git folders (repos). Repos []RepoInfo `tfsdk:"repos" tf:"optional"` } @@ -467,25 +503,21 @@ type RepoAccessControlResponse struct { UserName types.String `tfsdk:"user_name" tf:"optional"` } +// Git folder (repo) information. type RepoInfo struct { - // Branch that the local version of the repo is checked out to. + // Name of the current git branch of the git folder (repo). Branch types.String `tfsdk:"branch" tf:"optional"` - // SHA-1 hash representing the commit ID of the current HEAD of the repo. + // Current git commit id of the git folder (repo). HeadCommitId types.String `tfsdk:"head_commit_id" tf:"optional"` - // ID of the repo object in the workspace. + // Id of the git folder (repo) in the Workspace. Id types.Int64 `tfsdk:"id" tf:"optional"` - // Desired path for the repo in the workspace. Almost any path in the - // workspace can be chosen. If repo is created in /Repos, path must be in - // the format /Repos/{folder}/{repo-name}. + // Root path of the git folder (repo) in the Workspace. Path types.String `tfsdk:"path" tf:"optional"` - // Git provider. This field is case-insensitive. The available Git providers - // are gitHub, bitbucketCloud, gitLab, azureDevOpsServices, - // gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and - // awsCodeCommit. + // Git provider of the remote git repository, e.g. `gitHub`. Provider types.String `tfsdk:"provider" tf:"optional"` - + // Sparse checkout config for the git folder (repo). SparseCheckout *SparseCheckout `tfsdk:"sparse_checkout" tf:"optional"` - // URL of the Git repository to be linked. + // URL of the remote git repository. Url types.String `tfsdk:"url" tf:"optional"` } @@ -533,24 +565,32 @@ type SecretScope struct { Name types.String `tfsdk:"name" tf:"optional"` } +// Sparse checkout configuration, it contains options like cone patterns. type SparseCheckout struct { - // List of patterns to include for sparse checkout. + // List of sparse checkout cone patterns, see [cone mode handling] for + // details. + // + // [cone mode handling]: https://git-scm.com/docs/git-sparse-checkout#_internalscone_mode_handling Patterns []types.String `tfsdk:"patterns" tf:"optional"` } +// Sparse checkout configuration, it contains options like cone patterns. type SparseCheckoutUpdate struct { - // List of patterns to include for sparse checkout. + // List of sparse checkout cone patterns, see [cone mode handling] for + // details. + // + // [cone mode handling]: https://git-scm.com/docs/git-sparse-checkout#_internalscone_mode_handling Patterns []types.String `tfsdk:"patterns" tf:"optional"` } -type UpdateCredentials struct { +type UpdateCredentialsRequest struct { // The ID for the corresponding credential to access. CredentialId types.Int64 `tfsdk:"-"` // Git provider. This field is case-insensitive. The available Git providers - // are gitHub, bitbucketCloud, gitLab, azureDevOpsServices, - // gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and - // awsCodeCommit. - GitProvider types.String `tfsdk:"git_provider" tf:"optional"` + // are `gitHub`, `bitbucketCloud`, `gitLab`, `azureDevOpsServices`, + // `gitHubEnterprise`, `bitbucketServer`, `gitLabEnterpriseEdition` and + // `awsCodeCommit`. + GitProvider types.String `tfsdk:"git_provider" tf:""` // The username or email provided with your Git provider account, depending // on which provider you are using. For GitHub, GitHub Enterprise Server, or // Azure DevOps Services, either email or username may be used. For GitLab, @@ -561,17 +601,19 @@ type UpdateCredentials struct { GitUsername types.String `tfsdk:"git_username" tf:"optional"` // The personal access token used to authenticate to the corresponding Git // provider. For certain providers, support may exist for other types of - // scoped access tokens. [Learn more]. The personal access token used to - // authenticate to the corresponding Git + // scoped access tokens. [Learn more]. // // [Learn more]: https://docs.databricks.com/repos/get-access-tokens-from-git-provider.html PersonalAccessToken types.String `tfsdk:"personal_access_token" tf:"optional"` } -type UpdateRepo struct { +type UpdateCredentialsResponse struct { +} + +type UpdateRepoRequest struct { // Branch that the local version of the repo is checked out to. Branch types.String `tfsdk:"branch" tf:"optional"` - // The ID for the corresponding repo to access. + // ID of the Git folder (repo) object in the workspace. RepoId types.Int64 `tfsdk:"-"` // If specified, update the sparse checkout settings. The update will fail // if sparse checkout is not enabled for the repo. @@ -583,7 +625,7 @@ type UpdateRepo struct { Tag types.String `tfsdk:"tag" tf:"optional"` } -type UpdateResponse struct { +type UpdateRepoResponse struct { } type WorkspaceObjectAccessControlRequest struct { diff --git a/mlflow/data_mlflow_models.go b/mlflow/data_mlflow_models.go index 96ce6bed05..127b4f465f 100644 --- a/mlflow/data_mlflow_models.go +++ b/mlflow/data_mlflow_models.go @@ -2,6 +2,7 @@ package mlflow import ( "context" + "github.com/databricks/databricks-sdk-go/service/ml" "github.com/databricks/databricks-sdk-go" diff --git a/mlflow/data_mlflow_models_test.go b/mlflow/data_mlflow_models_test.go index b115ce9e23..04ff88be8d 100644 --- a/mlflow/data_mlflow_models_test.go +++ b/mlflow/data_mlflow_models_test.go @@ -1,9 +1,10 @@ package mlflow import ( + "testing" + "github.com/databricks/databricks-sdk-go/experimental/mocks" "github.com/stretchr/testify/mock" - "testing" "github.com/databricks/databricks-sdk-go/service/ml" "github.com/databricks/terraform-provider-databricks/qa" diff --git a/repos/resource_git_credential.go b/repos/resource_git_credential.go index 38f7b94044..9858ff9683 100644 --- a/repos/resource_git_credential.go +++ b/repos/resource_git_credential.go @@ -12,7 +12,7 @@ import ( ) func ResourceGitCredential() common.Resource { - s := common.StructToSchema(workspace.CreateCredentials{}, func(s map[string]*schema.Schema) map[string]*schema.Schema { + s := common.StructToSchema(workspace.CreateCredentialsRequest{}, func(s map[string]*schema.Schema) map[string]*schema.Schema { s["force"] = &schema.Schema{ Type: schema.TypeBool, Optional: true, @@ -34,7 +34,7 @@ func ResourceGitCredential() common.Resource { return err } - var req workspace.CreateCredentials + var req workspace.CreateCredentialsRequest common.DataToStructPointer(d, s, &req) resp, err := w.GitCredentials.Create(ctx, req) @@ -49,7 +49,7 @@ func ResourceGitCredential() common.Resource { if len(creds) != 1 { return fmt.Errorf("list of credentials is either empty or have more than one entry (%d)", len(creds)) } - var req workspace.UpdateCredentials + var req workspace.UpdateCredentialsRequest common.DataToStructPointer(d, s, &req) req.CredentialId = creds[0].CredentialId @@ -71,7 +71,7 @@ func ResourceGitCredential() common.Resource { if err != nil { return err } - resp, err := w.GitCredentials.Get(ctx, workspace.GetGitCredentialRequest{CredentialId: cred_id}) + resp, err := w.GitCredentials.Get(ctx, workspace.GetCredentialsRequest{CredentialId: cred_id}) if err != nil { return err } @@ -80,7 +80,7 @@ func ResourceGitCredential() common.Resource { return nil }, Update: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error { - var req workspace.UpdateCredentials + var req workspace.UpdateCredentialsRequest common.DataToStructPointer(d, s, &req) cred_id, err := strconv.ParseInt(d.Id(), 10, 64) diff --git a/repos/resource_git_credential_test.go b/repos/resource_git_credential_test.go index 911a48eeb0..1a64cf273c 100644 --- a/repos/resource_git_credential_test.go +++ b/repos/resource_git_credential_test.go @@ -85,7 +85,7 @@ func TestResourceGitCredentialUpdate(t *testing.T) { { Method: "PATCH", Resource: fmt.Sprintf("/api/2.0/git-credentials/%d", credID), - ExpectedRequest: workspace.UpdateCredentials{ + ExpectedRequest: workspace.UpdateCredentialsRequest{ CredentialId: int64(credID), GitProvider: provider, GitUsername: user, @@ -125,7 +125,7 @@ func TestResourceGitCredentialUpdate_Error(t *testing.T) { { Method: "PATCH", Resource: fmt.Sprintf("/api/2.0/git-credentials/%d", credID), - ExpectedRequest: workspace.UpdateCredentials{ + ExpectedRequest: workspace.UpdateCredentialsRequest{ CredentialId: int64(credID), GitProvider: provider, GitUsername: user, @@ -168,7 +168,7 @@ func TestResourceGitCredentialCreate(t *testing.T) { { Method: "POST", Resource: "/api/2.0/git-credentials", - ExpectedRequest: workspace.CreateCredentials{ + ExpectedRequest: workspace.CreateCredentialsRequest{ GitProvider: provider, GitUsername: user, PersonalAccessToken: token, @@ -200,7 +200,7 @@ func TestResourceGitCredentialCreate_Error(t *testing.T) { { Method: "POST", Resource: "/api/2.0/git-credentials", - ExpectedRequest: workspace.CreateCredentials{ + ExpectedRequest: workspace.CreateCredentialsRequest{ GitProvider: provider, GitUsername: user, PersonalAccessToken: token, @@ -236,7 +236,7 @@ func TestResourceGitCredentialCreateWithForce(t *testing.T) { { Method: "POST", Resource: "/api/2.0/git-credentials", - ExpectedRequest: workspace.CreateCredentials{ + ExpectedRequest: workspace.CreateCredentialsRequest{ GitProvider: provider, GitUsername: user, PersonalAccessToken: token, @@ -250,14 +250,14 @@ func TestResourceGitCredentialCreateWithForce(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/git-credentials", - Response: workspace.GetCredentialsResponse{ + Response: workspace.ListCredentialsResponse{ Credentials: []workspace.CredentialInfo{resp}, }, }, { Method: http.MethodPatch, Resource: fmt.Sprintf("/api/2.0/git-credentials/%d", resp.CredentialId), - ExpectedRequest: workspace.UpdateCredentials{ + ExpectedRequest: workspace.UpdateCredentialsRequest{ CredentialId: resp.CredentialId, GitProvider: provider, GitUsername: user, @@ -291,7 +291,7 @@ func TestResourceGitCredentialCreateWithForce_Error_List(t *testing.T) { { Method: "POST", Resource: "/api/2.0/git-credentials", - ExpectedRequest: workspace.CreateCredentials{ + ExpectedRequest: workspace.CreateCredentialsRequest{ GitProvider: provider, GitUsername: user, PersonalAccessToken: token, @@ -332,7 +332,7 @@ func TestResourceGitCredentialCreateWithForce_ErrorEmptyList(t *testing.T) { { Method: "POST", Resource: "/api/2.0/git-credentials", - ExpectedRequest: workspace.CreateCredentials{ + ExpectedRequest: workspace.CreateCredentialsRequest{ GitProvider: provider, GitUsername: user, PersonalAccessToken: token, @@ -374,7 +374,7 @@ func TestResourceGitCredentialCreateWithForce_ErrorUpdate(t *testing.T) { { Method: "POST", Resource: "/api/2.0/git-credentials", - ExpectedRequest: workspace.CreateCredentials{ + ExpectedRequest: workspace.CreateCredentialsRequest{ GitProvider: provider, GitUsername: user, PersonalAccessToken: token, @@ -388,7 +388,7 @@ func TestResourceGitCredentialCreateWithForce_ErrorUpdate(t *testing.T) { { Method: http.MethodGet, Resource: "/api/2.0/git-credentials", - Response: workspace.GetCredentialsResponse{ + Response: workspace.ListCredentialsResponse{ Credentials: []workspace.CredentialInfo{resp}, }, },