diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index 8622b29cac..a73d926a44 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -a6a317df8327c9b1e5cb59a03a42ffa2aabeef6d \ No newline at end of file +b23112e00949a153cb7ac738dc053430c8291086 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d021be4b6..350a569ab2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Version changelog +## [Release] Release v1.63.0 + +### Bug Fixes + + * Reflect backend updates in state for databricks_app ([#4337](https://github.com/databricks/terraform-provider-databricks/pull/4337)). + + +### Documentation + + * Update `databricks_workspace_conf` documentation ([#4334](https://github.com/databricks/terraform-provider-databricks/pull/4334)). + * apply `make fmt-docs` to all docs ([#4344](https://github.com/databricks/terraform-provider-databricks/pull/4344)). + + +### Internal Changes + + * Generate both SdkV2-compatible and Plugin Framework-compatible structures ([#4332](https://github.com/databricks/terraform-provider-databricks/pull/4332)). + * Mark TestAccServicePrincipalResourceOnAzure test as flaky ([#4333](https://github.com/databricks/terraform-provider-databricks/pull/4333)). + * Retry on 504 when calling the permission API ([#4355](https://github.com/databricks/terraform-provider-databricks/pull/4355)). + + ## [Release] Release v1.62.0 ### New Features and Improvements diff --git a/common/version.go b/common/version.go index 496a2de3b5..00acc23cde 100644 --- a/common/version.go +++ b/common/version.go @@ -3,7 +3,7 @@ package common import "context" var ( - version = "1.62.0" + version = "1.63.0" // ResourceName is resource name without databricks_ prefix ResourceName contextKey = 1 // Provider is the current instance of provider diff --git a/internal/service/jobs_tf/legacy_model.go b/internal/service/jobs_tf/legacy_model.go index 83f1687cd0..7321d48387 100755 --- a/internal/service/jobs_tf/legacy_model.go +++ b/internal/service/jobs_tf/legacy_model.go @@ -36,6 +36,11 @@ type BaseJob_SdkV2 struct { // based on accessible budget policies of the run_as identity on job // creation or modification. EffectiveBudgetPolicyId types.String `tfsdk:"effective_budget_policy_id" tf:"computed"` + // Indicates if the job has more sub-resources (`tasks`, `job_clusters`) + // that are not shown. They can be accessed via :method:jobs/get endpoint. + // It is only relevant for API 2.2 :method:jobs/list requests with + // `expand_tasks=true`. + HasMore types.Bool `tfsdk:"has_more" tf:"optional"` // The canonical identifier for this job. JobId types.Int64 `tfsdk:"job_id" tf:"optional"` // Settings for this job and all of its runs. These settings can be updated @@ -72,6 +77,7 @@ func (o BaseJob_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue "created_time": o.CreatedTime, "creator_user_name": o.CreatorUserName, "effective_budget_policy_id": o.EffectiveBudgetPolicyId, + "has_more": o.HasMore, "job_id": o.JobId, "settings": o.Settings, }) @@ -84,6 +90,7 @@ func (o BaseJob_SdkV2) Type(ctx context.Context) attr.Type { "created_time": types.Int64Type, "creator_user_name": types.StringType, "effective_budget_policy_id": types.StringType, + "has_more": types.BoolType, "job_id": types.Int64Type, "settings": basetypes.ListType{ ElemType: JobSettings_SdkV2{}.Type(ctx), @@ -167,9 +174,16 @@ type BaseRun_SdkV2 struct { // Note: dbt and SQL File tasks support only version-controlled sources. If // dbt or SQL File tasks are used, `git_source` must be defined on the job. GitSource types.List `tfsdk:"git_source" tf:"optional,object"` + // Indicates if the run has more sub-resources (`tasks`, `job_clusters`) + // that are not shown. They can be accessed via :method:jobs/getrun + // endpoint. It is only relevant for API 2.2 :method:jobs/listruns requests + // with `expand_tasks=true`. + HasMore types.Bool `tfsdk:"has_more" tf:"optional"` // A list of job cluster specifications that can be shared and reused by // tasks of this job. Libraries cannot be declared in a shared job cluster. - // You must declare dependent libraries in task settings. + // You must declare dependent libraries in task settings. If more than 100 + // job clusters are available, you can paginate through them using + // :method:jobs/getrun. JobClusters types.List `tfsdk:"job_clusters" tf:"optional"` // The canonical identifier of the job that contains this run. JobId types.Int64 `tfsdk:"job_id" tf:"optional"` @@ -231,7 +245,10 @@ type BaseRun_SdkV2 struct { // The current status of the run Status types.List `tfsdk:"status" tf:"optional,object"` // The list of tasks performed by the run. Each task has its own `run_id` - // which you can use to call `JobsGetOutput` to retrieve the run resutls. + // which you can use to call `JobsGetOutput` to retrieve the run resutls. If + // more than 100 tasks are available, you can paginate through them using + // :method:jobs/getrun. Use the `next_page_token` field at the object root + // to determine if more results are available. Tasks types.List `tfsdk:"tasks" tf:"optional"` // The type of trigger that fired this run. // @@ -296,6 +313,7 @@ func (o BaseRun_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue "end_time": o.EndTime, "execution_duration": o.ExecutionDuration, "git_source": o.GitSource, + "has_more": o.HasMore, "job_clusters": o.JobClusters, "job_id": o.JobId, "job_parameters": o.JobParameters, @@ -340,6 +358,7 @@ func (o BaseRun_SdkV2) Type(ctx context.Context) attr.Type { "git_source": basetypes.ListType{ ElemType: GitSource_SdkV2{}.Type(ctx), }, + "has_more": types.BoolType, "job_clusters": basetypes.ListType{ ElemType: JobCluster_SdkV2{}.Type(ctx), }, @@ -1326,7 +1345,9 @@ type CreateJob_SdkV2 struct { Health types.List `tfsdk:"health" tf:"optional,object"` // A list of job cluster specifications that can be shared and reused by // tasks of this job. Libraries cannot be declared in a shared job cluster. - // You must declare dependent libraries in task settings. + // You must declare dependent libraries in task settings. If more than 100 + // job clusters are available, you can paginate through them using + // :method:jobs/get. JobClusters types.List `tfsdk:"job_cluster" tf:"optional"` // An optional maximum allowed number of concurrent runs of the job. Set // this value if you want to be able to execute multiple runs of the same @@ -1366,7 +1387,10 @@ type CreateJob_SdkV2 struct { // limitations as cluster tags. A maximum of 25 tags can be added to the // job. Tags types.Map `tfsdk:"tags" tf:"optional"` - // A list of task specifications to be executed by this job. + // A list of task specifications to be executed by this job. If more than + // 100 tasks are available, you can paginate through them using + // :method:jobs/get. Use the `next_page_token` field at the object root to + // determine if more results are available. Tasks types.List `tfsdk:"task" tf:"optional"` // An optional timeout applied to each run of this job. A value of `0` means // no timeout. @@ -3275,6 +3299,9 @@ type GetJobRequest_SdkV2 struct { // The canonical identifier of the job to retrieve information about. This // field is required. JobId types.Int64 `tfsdk:"-"` + // Use `next_page_token` returned from the previous GetJob to request the + // next page of the job's sub-resources. + PageToken types.String `tfsdk:"-"` } func (newState *GetJobRequest_SdkV2) SyncEffectiveFieldsDuringCreateOrUpdate(plan GetJobRequest_SdkV2) { @@ -3301,7 +3328,8 @@ func (o GetJobRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.Object return types.ObjectValueMust( o.Type(ctx).(basetypes.ObjectType).AttrTypes, map[string]attr.Value{ - "job_id": o.JobId, + "job_id": o.JobId, + "page_token": o.PageToken, }) } @@ -3309,7 +3337,8 @@ func (o GetJobRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.Object func (o GetJobRequest_SdkV2) Type(ctx context.Context) attr.Type { return types.ObjectType{ AttrTypes: map[string]attr.Type{ - "job_id": types.Int64Type, + "job_id": types.Int64Type, + "page_token": types.StringType, }, } } @@ -3489,8 +3518,8 @@ type GetRunRequest_SdkV2 struct { IncludeHistory types.Bool `tfsdk:"-"` // Whether to include resolved parameter values in the response. IncludeResolvedValues types.Bool `tfsdk:"-"` - // To list the next page of job tasks, set this field to the value of the - // `next_page_token` returned in the GetJob response. + // Use `next_page_token` returned from the previous GetRun to request the + // next page of the run's sub-resources. PageToken types.String `tfsdk:"-"` // The canonical identifier of the run for which to retrieve the metadata. // This field is required. @@ -3742,8 +3771,15 @@ type Job_SdkV2 struct { // based on accessible budget policies of the run_as identity on job // creation or modification. EffectiveBudgetPolicyId types.String `tfsdk:"effective_budget_policy_id" tf:"computed"` + // Indicates if the job has more sub-resources (`tasks`, `job_clusters`) + // that are not shown. They can be accessed via :method:jobs/get endpoint. + // It is only relevant for API 2.2 :method:jobs/list requests with + // `expand_tasks=true`. + HasMore types.Bool `tfsdk:"has_more" tf:"optional"` // The canonical identifier for this job. JobId types.Int64 `tfsdk:"job_id" tf:"optional"` + // A token that can be used to list the next page of sub-resources. + NextPageToken types.String `tfsdk:"next_page_token" tf:"optional"` // The email of an active workspace user or the application ID of a service // principal that the job runs as. This value can be changed by setting the // `run_as` field when creating or updating a job. @@ -3786,7 +3822,9 @@ func (o Job_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "created_time": o.CreatedTime, "creator_user_name": o.CreatorUserName, "effective_budget_policy_id": o.EffectiveBudgetPolicyId, + "has_more": o.HasMore, "job_id": o.JobId, + "next_page_token": o.NextPageToken, "run_as_user_name": o.RunAsUserName, "settings": o.Settings, }) @@ -3799,7 +3837,9 @@ func (o Job_SdkV2) Type(ctx context.Context) attr.Type { "created_time": types.Int64Type, "creator_user_name": types.StringType, "effective_budget_policy_id": types.StringType, + "has_more": types.BoolType, "job_id": types.Int64Type, + "next_page_token": types.StringType, "run_as_user_name": types.StringType, "settings": basetypes.ListType{ ElemType: JobSettings_SdkV2{}.Type(ctx), @@ -5018,7 +5058,9 @@ type JobSettings_SdkV2 struct { Health types.List `tfsdk:"health" tf:"optional,object"` // A list of job cluster specifications that can be shared and reused by // tasks of this job. Libraries cannot be declared in a shared job cluster. - // You must declare dependent libraries in task settings. + // You must declare dependent libraries in task settings. If more than 100 + // job clusters are available, you can paginate through them using + // :method:jobs/get. JobClusters types.List `tfsdk:"job_cluster" tf:"optional"` // An optional maximum allowed number of concurrent runs of the job. Set // this value if you want to be able to execute multiple runs of the same @@ -5058,7 +5100,10 @@ type JobSettings_SdkV2 struct { // limitations as cluster tags. A maximum of 25 tags can be added to the // job. Tags types.Map `tfsdk:"tags" tf:"optional"` - // A list of task specifications to be executed by this job. + // A list of task specifications to be executed by this job. If more than + // 100 tasks are available, you can paginate through them using + // :method:jobs/get. Use the `next_page_token` field at the object root to + // determine if more results are available. Tasks types.List `tfsdk:"task" tf:"optional"` // An optional timeout applied to each run of this job. A value of `0` means // no timeout. @@ -5953,7 +5998,9 @@ func (o ListJobComplianceRequest_SdkV2) Type(ctx context.Context) attr.Type { // List jobs type ListJobsRequest_SdkV2 struct { - // Whether to include task and cluster details in the response. + // Whether to include task and cluster details in the response. Note that in + // API 2.2, only the first 100 elements will be shown. Use :method:jobs/get + // to paginate through all tasks and clusters. ExpandTasks types.Bool `tfsdk:"-"` // The number of jobs to return. This value must be greater than 0 and less // or equal to 100. The default value is 20. @@ -6113,7 +6160,9 @@ type ListRunsRequest_SdkV2 struct { // results; otherwise, lists both active and completed runs. This field // cannot be `true` when active_only is `true`. CompletedOnly types.Bool `tfsdk:"-"` - // Whether to include task and cluster details in the response. + // Whether to include task and cluster details in the response. Note that in + // API 2.2, only the first 100 elements will be shown. Use + // :method:jobs/getrun to paginate through all tasks and clusters. ExpandTasks types.Bool `tfsdk:"-"` // The job for which to list runs. If omitted, the Jobs service lists runs // from all jobs. @@ -8525,12 +8574,19 @@ type Run_SdkV2 struct { // Note: dbt and SQL File tasks support only version-controlled sources. If // dbt or SQL File tasks are used, `git_source` must be defined on the job. GitSource types.List `tfsdk:"git_source" tf:"optional,object"` + // Indicates if the run has more sub-resources (`tasks`, `job_clusters`) + // that are not shown. They can be accessed via :method:jobs/getrun + // endpoint. It is only relevant for API 2.2 :method:jobs/listruns requests + // with `expand_tasks=true`. + HasMore types.Bool `tfsdk:"has_more" tf:"optional"` // Only populated by for-each iterations. The parent for-each task is // located in tasks array. Iterations types.List `tfsdk:"iterations" tf:"optional"` // A list of job cluster specifications that can be shared and reused by // tasks of this job. Libraries cannot be declared in a shared job cluster. - // You must declare dependent libraries in task settings. + // You must declare dependent libraries in task settings. If more than 100 + // job clusters are available, you can paginate through them using + // :method:jobs/getrun. JobClusters types.List `tfsdk:"job_clusters" tf:"optional"` // The canonical identifier of the job that contains this run. JobId types.Int64 `tfsdk:"job_id" tf:"optional"` @@ -8594,7 +8650,10 @@ type Run_SdkV2 struct { // The current status of the run Status types.List `tfsdk:"status" tf:"optional,object"` // The list of tasks performed by the run. Each task has its own `run_id` - // which you can use to call `JobsGetOutput` to retrieve the run resutls. + // which you can use to call `JobsGetOutput` to retrieve the run resutls. If + // more than 100 tasks are available, you can paginate through them using + // :method:jobs/getrun. Use the `next_page_token` field at the object root + // to determine if more results are available. Tasks types.List `tfsdk:"tasks" tf:"optional"` // The type of trigger that fired this run. // @@ -8660,6 +8719,7 @@ func (o Run_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "end_time": o.EndTime, "execution_duration": o.ExecutionDuration, "git_source": o.GitSource, + "has_more": o.HasMore, "iterations": o.Iterations, "job_clusters": o.JobClusters, "job_id": o.JobId, @@ -8706,6 +8766,7 @@ func (o Run_SdkV2) Type(ctx context.Context) attr.Type { "git_source": basetypes.ListType{ ElemType: GitSource_SdkV2{}.Type(ctx), }, + "has_more": types.BoolType, "iterations": basetypes.ListType{ ElemType: RunTask_SdkV2{}.Type(ctx), }, diff --git a/internal/service/jobs_tf/model.go b/internal/service/jobs_tf/model.go index 954b2faec6..cd13c4eabf 100755 --- a/internal/service/jobs_tf/model.go +++ b/internal/service/jobs_tf/model.go @@ -36,6 +36,11 @@ type BaseJob struct { // based on accessible budget policies of the run_as identity on job // creation or modification. EffectiveBudgetPolicyId types.String `tfsdk:"effective_budget_policy_id" tf:"computed"` + // Indicates if the job has more sub-resources (`tasks`, `job_clusters`) + // that are not shown. They can be accessed via :method:jobs/get endpoint. + // It is only relevant for API 2.2 :method:jobs/list requests with + // `expand_tasks=true`. + HasMore types.Bool `tfsdk:"has_more" tf:"optional"` // The canonical identifier for this job. JobId types.Int64 `tfsdk:"job_id" tf:"optional"` // Settings for this job and all of its runs. These settings can be updated @@ -72,6 +77,7 @@ func (o BaseJob) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "created_time": o.CreatedTime, "creator_user_name": o.CreatorUserName, "effective_budget_policy_id": o.EffectiveBudgetPolicyId, + "has_more": o.HasMore, "job_id": o.JobId, "settings": o.Settings, }) @@ -84,6 +90,7 @@ func (o BaseJob) Type(ctx context.Context) attr.Type { "created_time": types.Int64Type, "creator_user_name": types.StringType, "effective_budget_policy_id": types.StringType, + "has_more": types.BoolType, "job_id": types.Int64Type, "settings": JobSettings{}.Type(ctx), }, @@ -167,9 +174,16 @@ type BaseRun struct { // Note: dbt and SQL File tasks support only version-controlled sources. If // dbt or SQL File tasks are used, `git_source` must be defined on the job. GitSource types.Object `tfsdk:"git_source" tf:"optional,object"` + // Indicates if the run has more sub-resources (`tasks`, `job_clusters`) + // that are not shown. They can be accessed via :method:jobs/getrun + // endpoint. It is only relevant for API 2.2 :method:jobs/listruns requests + // with `expand_tasks=true`. + HasMore types.Bool `tfsdk:"has_more" tf:"optional"` // A list of job cluster specifications that can be shared and reused by // tasks of this job. Libraries cannot be declared in a shared job cluster. - // You must declare dependent libraries in task settings. + // You must declare dependent libraries in task settings. If more than 100 + // job clusters are available, you can paginate through them using + // :method:jobs/getrun. JobClusters types.List `tfsdk:"job_clusters" tf:"optional"` // The canonical identifier of the job that contains this run. JobId types.Int64 `tfsdk:"job_id" tf:"optional"` @@ -231,7 +245,10 @@ type BaseRun struct { // The current status of the run Status types.Object `tfsdk:"status" tf:"optional,object"` // The list of tasks performed by the run. Each task has its own `run_id` - // which you can use to call `JobsGetOutput` to retrieve the run resutls. + // which you can use to call `JobsGetOutput` to retrieve the run resutls. If + // more than 100 tasks are available, you can paginate through them using + // :method:jobs/getrun. Use the `next_page_token` field at the object root + // to determine if more results are available. Tasks types.List `tfsdk:"tasks" tf:"optional"` // The type of trigger that fired this run. // @@ -296,6 +313,7 @@ func (o BaseRun) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "end_time": o.EndTime, "execution_duration": o.ExecutionDuration, "git_source": o.GitSource, + "has_more": o.HasMore, "job_clusters": o.JobClusters, "job_id": o.JobId, "job_parameters": o.JobParameters, @@ -334,6 +352,7 @@ func (o BaseRun) Type(ctx context.Context) attr.Type { "end_time": types.Int64Type, "execution_duration": types.Int64Type, "git_source": GitSource{}.Type(ctx), + "has_more": types.BoolType, "job_clusters": basetypes.ListType{ ElemType: JobCluster{}.Type(ctx), }, @@ -1326,7 +1345,9 @@ type CreateJob struct { Health types.Object `tfsdk:"health" tf:"optional,object"` // A list of job cluster specifications that can be shared and reused by // tasks of this job. Libraries cannot be declared in a shared job cluster. - // You must declare dependent libraries in task settings. + // You must declare dependent libraries in task settings. If more than 100 + // job clusters are available, you can paginate through them using + // :method:jobs/get. JobClusters types.List `tfsdk:"job_cluster" tf:"optional"` // An optional maximum allowed number of concurrent runs of the job. Set // this value if you want to be able to execute multiple runs of the same @@ -1366,7 +1387,10 @@ type CreateJob struct { // limitations as cluster tags. A maximum of 25 tags can be added to the // job. Tags types.Map `tfsdk:"tags" tf:"optional"` - // A list of task specifications to be executed by this job. + // A list of task specifications to be executed by this job. If more than + // 100 tasks are available, you can paginate through them using + // :method:jobs/get. Use the `next_page_token` field at the object root to + // determine if more results are available. Tasks types.List `tfsdk:"task" tf:"optional"` // An optional timeout applied to each run of this job. A value of `0` means // no timeout. @@ -3275,6 +3299,9 @@ type GetJobRequest struct { // The canonical identifier of the job to retrieve information about. This // field is required. JobId types.Int64 `tfsdk:"-"` + // Use `next_page_token` returned from the previous GetJob to request the + // next page of the job's sub-resources. + PageToken types.String `tfsdk:"-"` } func (newState *GetJobRequest) SyncEffectiveFieldsDuringCreateOrUpdate(plan GetJobRequest) { @@ -3301,7 +3328,8 @@ func (o GetJobRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue return types.ObjectValueMust( o.Type(ctx).(basetypes.ObjectType).AttrTypes, map[string]attr.Value{ - "job_id": o.JobId, + "job_id": o.JobId, + "page_token": o.PageToken, }) } @@ -3309,7 +3337,8 @@ func (o GetJobRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue func (o GetJobRequest) Type(ctx context.Context) attr.Type { return types.ObjectType{ AttrTypes: map[string]attr.Type{ - "job_id": types.Int64Type, + "job_id": types.Int64Type, + "page_token": types.StringType, }, } } @@ -3489,8 +3518,8 @@ type GetRunRequest struct { IncludeHistory types.Bool `tfsdk:"-"` // Whether to include resolved parameter values in the response. IncludeResolvedValues types.Bool `tfsdk:"-"` - // To list the next page of job tasks, set this field to the value of the - // `next_page_token` returned in the GetJob response. + // Use `next_page_token` returned from the previous GetRun to request the + // next page of the run's sub-resources. PageToken types.String `tfsdk:"-"` // The canonical identifier of the run for which to retrieve the metadata. // This field is required. @@ -3742,8 +3771,15 @@ type Job struct { // based on accessible budget policies of the run_as identity on job // creation or modification. EffectiveBudgetPolicyId types.String `tfsdk:"effective_budget_policy_id" tf:"computed"` + // Indicates if the job has more sub-resources (`tasks`, `job_clusters`) + // that are not shown. They can be accessed via :method:jobs/get endpoint. + // It is only relevant for API 2.2 :method:jobs/list requests with + // `expand_tasks=true`. + HasMore types.Bool `tfsdk:"has_more" tf:"optional"` // The canonical identifier for this job. JobId types.Int64 `tfsdk:"job_id" tf:"optional"` + // A token that can be used to list the next page of sub-resources. + NextPageToken types.String `tfsdk:"next_page_token" tf:"optional"` // The email of an active workspace user or the application ID of a service // principal that the job runs as. This value can be changed by setting the // `run_as` field when creating or updating a job. @@ -3786,7 +3822,9 @@ func (o Job) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "created_time": o.CreatedTime, "creator_user_name": o.CreatorUserName, "effective_budget_policy_id": o.EffectiveBudgetPolicyId, + "has_more": o.HasMore, "job_id": o.JobId, + "next_page_token": o.NextPageToken, "run_as_user_name": o.RunAsUserName, "settings": o.Settings, }) @@ -3799,7 +3837,9 @@ func (o Job) Type(ctx context.Context) attr.Type { "created_time": types.Int64Type, "creator_user_name": types.StringType, "effective_budget_policy_id": types.StringType, + "has_more": types.BoolType, "job_id": types.Int64Type, + "next_page_token": types.StringType, "run_as_user_name": types.StringType, "settings": JobSettings{}.Type(ctx), }, @@ -5018,7 +5058,9 @@ type JobSettings struct { Health types.Object `tfsdk:"health" tf:"optional,object"` // A list of job cluster specifications that can be shared and reused by // tasks of this job. Libraries cannot be declared in a shared job cluster. - // You must declare dependent libraries in task settings. + // You must declare dependent libraries in task settings. If more than 100 + // job clusters are available, you can paginate through them using + // :method:jobs/get. JobClusters types.List `tfsdk:"job_cluster" tf:"optional"` // An optional maximum allowed number of concurrent runs of the job. Set // this value if you want to be able to execute multiple runs of the same @@ -5058,7 +5100,10 @@ type JobSettings struct { // limitations as cluster tags. A maximum of 25 tags can be added to the // job. Tags types.Map `tfsdk:"tags" tf:"optional"` - // A list of task specifications to be executed by this job. + // A list of task specifications to be executed by this job. If more than + // 100 tasks are available, you can paginate through them using + // :method:jobs/get. Use the `next_page_token` field at the object root to + // determine if more results are available. Tasks types.List `tfsdk:"task" tf:"optional"` // An optional timeout applied to each run of this job. A value of `0` means // no timeout. @@ -5953,7 +5998,9 @@ func (o ListJobComplianceRequest) Type(ctx context.Context) attr.Type { // List jobs type ListJobsRequest struct { - // Whether to include task and cluster details in the response. + // Whether to include task and cluster details in the response. Note that in + // API 2.2, only the first 100 elements will be shown. Use :method:jobs/get + // to paginate through all tasks and clusters. ExpandTasks types.Bool `tfsdk:"-"` // The number of jobs to return. This value must be greater than 0 and less // or equal to 100. The default value is 20. @@ -6113,7 +6160,9 @@ type ListRunsRequest struct { // results; otherwise, lists both active and completed runs. This field // cannot be `true` when active_only is `true`. CompletedOnly types.Bool `tfsdk:"-"` - // Whether to include task and cluster details in the response. + // Whether to include task and cluster details in the response. Note that in + // API 2.2, only the first 100 elements will be shown. Use + // :method:jobs/getrun to paginate through all tasks and clusters. ExpandTasks types.Bool `tfsdk:"-"` // The job for which to list runs. If omitted, the Jobs service lists runs // from all jobs. @@ -8525,12 +8574,19 @@ type Run struct { // Note: dbt and SQL File tasks support only version-controlled sources. If // dbt or SQL File tasks are used, `git_source` must be defined on the job. GitSource types.Object `tfsdk:"git_source" tf:"optional,object"` + // Indicates if the run has more sub-resources (`tasks`, `job_clusters`) + // that are not shown. They can be accessed via :method:jobs/getrun + // endpoint. It is only relevant for API 2.2 :method:jobs/listruns requests + // with `expand_tasks=true`. + HasMore types.Bool `tfsdk:"has_more" tf:"optional"` // Only populated by for-each iterations. The parent for-each task is // located in tasks array. Iterations types.List `tfsdk:"iterations" tf:"optional"` // A list of job cluster specifications that can be shared and reused by // tasks of this job. Libraries cannot be declared in a shared job cluster. - // You must declare dependent libraries in task settings. + // You must declare dependent libraries in task settings. If more than 100 + // job clusters are available, you can paginate through them using + // :method:jobs/getrun. JobClusters types.List `tfsdk:"job_clusters" tf:"optional"` // The canonical identifier of the job that contains this run. JobId types.Int64 `tfsdk:"job_id" tf:"optional"` @@ -8594,7 +8650,10 @@ type Run struct { // The current status of the run Status types.Object `tfsdk:"status" tf:"optional,object"` // The list of tasks performed by the run. Each task has its own `run_id` - // which you can use to call `JobsGetOutput` to retrieve the run resutls. + // which you can use to call `JobsGetOutput` to retrieve the run resutls. If + // more than 100 tasks are available, you can paginate through them using + // :method:jobs/getrun. Use the `next_page_token` field at the object root + // to determine if more results are available. Tasks types.List `tfsdk:"tasks" tf:"optional"` // The type of trigger that fired this run. // @@ -8660,6 +8719,7 @@ func (o Run) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "end_time": o.EndTime, "execution_duration": o.ExecutionDuration, "git_source": o.GitSource, + "has_more": o.HasMore, "iterations": o.Iterations, "job_clusters": o.JobClusters, "job_id": o.JobId, @@ -8700,6 +8760,7 @@ func (o Run) Type(ctx context.Context) attr.Type { "end_time": types.Int64Type, "execution_duration": types.Int64Type, "git_source": GitSource{}.Type(ctx), + "has_more": types.BoolType, "iterations": basetypes.ListType{ ElemType: RunTask{}.Type(ctx), }, diff --git a/internal/service/oauth2_tf/legacy_model.go b/internal/service/oauth2_tf/legacy_model.go index a11894aa5a..3836ba51a8 100755 --- a/internal/service/oauth2_tf/legacy_model.go +++ b/internal/service/oauth2_tf/legacy_model.go @@ -24,8 +24,9 @@ import ( // Create account federation policy type CreateAccountFederationPolicyRequest_SdkV2 struct { Policy types.List `tfsdk:"policy" tf:"optional,object"` - // The identifier for the federation policy. If unspecified, the id will be - // assigned by Databricks. + // The identifier for the federation policy. The identifier must contain + // only lowercase alphanumeric characters, numbers, hyphens, and slashes. If + // unspecified, the id will be assigned by Databricks. PolicyId types.String `tfsdk:"-"` } @@ -419,8 +420,9 @@ func (o CreatePublishedAppIntegrationOutput_SdkV2) Type(ctx context.Context) att // Create service principal federation policy type CreateServicePrincipalFederationPolicyRequest_SdkV2 struct { Policy types.List `tfsdk:"policy" tf:"optional,object"` - // The identifier for the federation policy. If unspecified, the id will be - // assigned by Databricks. + // The identifier for the federation policy. The identifier must contain + // only lowercase alphanumeric characters, numbers, hyphens, and slashes. If + // unspecified, the id will be assigned by Databricks. PolicyId types.String `tfsdk:"-"` // The service principal id for the federation policy. ServicePrincipalId types.Int64 `tfsdk:"-"` @@ -650,6 +652,7 @@ func (o DataPlaneInfo_SdkV2) Type(ctx context.Context) attr.Type { // Delete account federation policy type DeleteAccountFederationPolicyRequest_SdkV2 struct { + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` } @@ -884,6 +887,7 @@ func (o DeleteResponse_SdkV2) Type(ctx context.Context) attr.Type { // Delete service principal federation policy type DeleteServicePrincipalFederationPolicyRequest_SdkV2 struct { + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` // The service principal id for the federation policy. ServicePrincipalId types.Int64 `tfsdk:"-"` @@ -980,9 +984,13 @@ type FederationPolicy_SdkV2 struct { CreateTime types.String `tfsdk:"create_time" tf:"computed"` // Description of the federation policy. Description types.String `tfsdk:"description" tf:"optional"` - // Name of the federation policy. The name must contain only lowercase - // alphanumeric characters, numbers, and hyphens. It must be unique within - // the account. + // Resource name for the federation policy. Example values include + // `accounts//federationPolicies/my-federation-policy` for + // Account Federation Policies, and + // `accounts//servicePrincipals//federationPolicies/my-federation-policy` + // for Service Principal Federation Policies. Typically an output parameter, + // which does not need to be specified in create or update requests. If + // specified in a request, must match the value in the request URL. Name types.String `tfsdk:"name" tf:"optional"` // Specifies the policy to use for validating OIDC claims in your federated // tokens. @@ -1072,6 +1080,7 @@ func (o *FederationPolicy_SdkV2) SetOidcPolicy(ctx context.Context, v OidcFedera // Get account federation policy type GetAccountFederationPolicyRequest_SdkV2 struct { + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` } @@ -1687,6 +1696,7 @@ func (o *GetPublishedAppsOutput_SdkV2) SetApps(ctx context.Context, v []Publishe // Get service principal federation policy type GetServicePrincipalFederationPolicyRequest_SdkV2 struct { + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` // The service principal id for the federation policy. ServicePrincipalId types.Int64 `tfsdk:"-"` @@ -2513,7 +2523,7 @@ func (o TokenAccessPolicy_SdkV2) Type(ctx context.Context) attr.Type { // Update account federation policy type UpdateAccountFederationPolicyRequest_SdkV2 struct { Policy types.List `tfsdk:"policy" tf:"optional,object"` - + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` // Field mask is required to be passed into the PATCH request. Field mask // specifies which fields of the setting payload will be updated. The field @@ -2852,7 +2862,7 @@ func (o UpdatePublishedAppIntegrationOutput_SdkV2) Type(ctx context.Context) att // Update service principal federation policy type UpdateServicePrincipalFederationPolicyRequest_SdkV2 struct { Policy types.List `tfsdk:"policy" tf:"optional,object"` - + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` // The service principal id for the federation policy. ServicePrincipalId types.Int64 `tfsdk:"-"` diff --git a/internal/service/oauth2_tf/model.go b/internal/service/oauth2_tf/model.go index 6f63b32b00..c774d2e7f8 100755 --- a/internal/service/oauth2_tf/model.go +++ b/internal/service/oauth2_tf/model.go @@ -24,8 +24,9 @@ import ( // Create account federation policy type CreateAccountFederationPolicyRequest struct { Policy types.Object `tfsdk:"policy" tf:"optional,object"` - // The identifier for the federation policy. If unspecified, the id will be - // assigned by Databricks. + // The identifier for the federation policy. The identifier must contain + // only lowercase alphanumeric characters, numbers, hyphens, and slashes. If + // unspecified, the id will be assigned by Databricks. PolicyId types.String `tfsdk:"-"` } @@ -419,8 +420,9 @@ func (o CreatePublishedAppIntegrationOutput) Type(ctx context.Context) attr.Type // Create service principal federation policy type CreateServicePrincipalFederationPolicyRequest struct { Policy types.Object `tfsdk:"policy" tf:"optional,object"` - // The identifier for the federation policy. If unspecified, the id will be - // assigned by Databricks. + // The identifier for the federation policy. The identifier must contain + // only lowercase alphanumeric characters, numbers, hyphens, and slashes. If + // unspecified, the id will be assigned by Databricks. PolicyId types.String `tfsdk:"-"` // The service principal id for the federation policy. ServicePrincipalId types.Int64 `tfsdk:"-"` @@ -650,6 +652,7 @@ func (o DataPlaneInfo) Type(ctx context.Context) attr.Type { // Delete account federation policy type DeleteAccountFederationPolicyRequest struct { + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` } @@ -884,6 +887,7 @@ func (o DeleteResponse) Type(ctx context.Context) attr.Type { // Delete service principal federation policy type DeleteServicePrincipalFederationPolicyRequest struct { + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` // The service principal id for the federation policy. ServicePrincipalId types.Int64 `tfsdk:"-"` @@ -980,9 +984,13 @@ type FederationPolicy struct { CreateTime types.String `tfsdk:"create_time" tf:"computed"` // Description of the federation policy. Description types.String `tfsdk:"description" tf:"optional"` - // Name of the federation policy. The name must contain only lowercase - // alphanumeric characters, numbers, and hyphens. It must be unique within - // the account. + // Resource name for the federation policy. Example values include + // `accounts//federationPolicies/my-federation-policy` for + // Account Federation Policies, and + // `accounts//servicePrincipals//federationPolicies/my-federation-policy` + // for Service Principal Federation Policies. Typically an output parameter, + // which does not need to be specified in create or update requests. If + // specified in a request, must match the value in the request URL. Name types.String `tfsdk:"name" tf:"optional"` // Specifies the policy to use for validating OIDC claims in your federated // tokens. @@ -1072,6 +1080,7 @@ func (o *FederationPolicy) SetOidcPolicy(ctx context.Context, v OidcFederationPo // Get account federation policy type GetAccountFederationPolicyRequest struct { + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` } @@ -1687,6 +1696,7 @@ func (o *GetPublishedAppsOutput) SetApps(ctx context.Context, v []PublishedAppOu // Get service principal federation policy type GetServicePrincipalFederationPolicyRequest struct { + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` // The service principal id for the federation policy. ServicePrincipalId types.Int64 `tfsdk:"-"` @@ -2513,7 +2523,7 @@ func (o TokenAccessPolicy) Type(ctx context.Context) attr.Type { // Update account federation policy type UpdateAccountFederationPolicyRequest struct { Policy types.Object `tfsdk:"policy" tf:"optional,object"` - + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` // Field mask is required to be passed into the PATCH request. Field mask // specifies which fields of the setting payload will be updated. The field @@ -2852,7 +2862,7 @@ func (o UpdatePublishedAppIntegrationOutput) Type(ctx context.Context) attr.Type // Update service principal federation policy type UpdateServicePrincipalFederationPolicyRequest struct { Policy types.Object `tfsdk:"policy" tf:"optional,object"` - + // The identifier for the federation policy. PolicyId types.String `tfsdk:"-"` // The service principal id for the federation policy. ServicePrincipalId types.Int64 `tfsdk:"-"` diff --git a/internal/service/pipelines_tf/legacy_model.go b/internal/service/pipelines_tf/legacy_model.go index 35df38afc2..309b54efa6 100755 --- a/internal/service/pipelines_tf/legacy_model.go +++ b/internal/service/pipelines_tf/legacy_model.go @@ -69,6 +69,13 @@ type CreatePipeline_SdkV2 struct { Photon types.Bool `tfsdk:"photon" tf:"optional"` // Restart window of this pipeline. RestartWindow types.List `tfsdk:"restart_window" tf:"optional,object"` + // Write-only setting, available only in Create/Update calls. Specifies the + // user or service principal that the pipeline runs as. If not specified, + // the pipeline runs as the user who created the pipeline. + // + // Only `user_name` or `service_principal_name` can be specified. If both + // are specified, an error is thrown. + RunAs types.List `tfsdk:"run_as" tf:"optional,object"` // 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. @@ -109,6 +116,7 @@ func (a CreatePipeline_SdkV2) GetComplexFieldTypes(ctx context.Context) map[stri "libraries": reflect.TypeOf(PipelineLibrary_SdkV2{}), "notifications": reflect.TypeOf(Notifications_SdkV2{}), "restart_window": reflect.TypeOf(RestartWindow_SdkV2{}), + "run_as": reflect.TypeOf(RunAs_SdkV2{}), "trigger": reflect.TypeOf(PipelineTrigger_SdkV2{}), } } @@ -140,6 +148,7 @@ func (o CreatePipeline_SdkV2) ToObjectValue(ctx context.Context) basetypes.Objec "notifications": o.Notifications, "photon": o.Photon, "restart_window": o.RestartWindow, + "run_as": o.RunAs, "schema": o.Schema, "serverless": o.Serverless, "storage": o.Storage, @@ -190,6 +199,9 @@ func (o CreatePipeline_SdkV2) Type(ctx context.Context) attr.Type { "restart_window": basetypes.ListType{ ElemType: RestartWindow_SdkV2{}.Type(ctx), }, + "run_as": basetypes.ListType{ + ElemType: RunAs_SdkV2{}.Type(ctx), + }, "schema": types.StringType, "serverless": types.BoolType, "storage": types.StringType, @@ -435,6 +447,32 @@ func (o *CreatePipeline_SdkV2) SetRestartWindow(ctx context.Context, v RestartWi o.RestartWindow = types.ListValueMust(t, vs) } +// GetRunAs returns the value of the RunAs field in CreatePipeline_SdkV2 as +// a RunAs_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (o *CreatePipeline_SdkV2) GetRunAs(ctx context.Context) (RunAs_SdkV2, bool) { + var e RunAs_SdkV2 + if o.RunAs.IsNull() || o.RunAs.IsUnknown() { + return e, false + } + var v []RunAs_SdkV2 + d := o.RunAs.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetRunAs sets the value of the RunAs field in CreatePipeline_SdkV2. +func (o *CreatePipeline_SdkV2) SetRunAs(ctx context.Context, v RunAs_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := o.Type(ctx).(basetypes.ObjectType).AttrTypes["run_as"] + o.RunAs = types.ListValueMust(t, vs) +} + // GetTrigger returns the value of the Trigger field in CreatePipeline_SdkV2 as // a PipelineTrigger_SdkV2 value. // If the field is unknown or null, the boolean return value is false. @@ -758,6 +796,13 @@ type EditPipeline_SdkV2 struct { PipelineId types.String `tfsdk:"pipeline_id" tf:"optional"` // Restart window of this pipeline. RestartWindow types.List `tfsdk:"restart_window" tf:"optional,object"` + // Write-only setting, available only in Create/Update calls. Specifies the + // user or service principal that the pipeline runs as. If not specified, + // the pipeline runs as the user who created the pipeline. + // + // Only `user_name` or `service_principal_name` can be specified. If both + // are specified, an error is thrown. + RunAs types.List `tfsdk:"run_as" tf:"optional,object"` // 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. @@ -798,6 +843,7 @@ func (a EditPipeline_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string "libraries": reflect.TypeOf(PipelineLibrary_SdkV2{}), "notifications": reflect.TypeOf(Notifications_SdkV2{}), "restart_window": reflect.TypeOf(RestartWindow_SdkV2{}), + "run_as": reflect.TypeOf(RunAs_SdkV2{}), "trigger": reflect.TypeOf(PipelineTrigger_SdkV2{}), } } @@ -830,6 +876,7 @@ func (o EditPipeline_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectV "photon": o.Photon, "pipeline_id": o.PipelineId, "restart_window": o.RestartWindow, + "run_as": o.RunAs, "schema": o.Schema, "serverless": o.Serverless, "storage": o.Storage, @@ -881,6 +928,9 @@ func (o EditPipeline_SdkV2) Type(ctx context.Context) attr.Type { "restart_window": basetypes.ListType{ ElemType: RestartWindow_SdkV2{}.Type(ctx), }, + "run_as": basetypes.ListType{ + ElemType: RunAs_SdkV2{}.Type(ctx), + }, "schema": types.StringType, "serverless": types.BoolType, "storage": types.StringType, @@ -1126,6 +1176,32 @@ func (o *EditPipeline_SdkV2) SetRestartWindow(ctx context.Context, v RestartWind o.RestartWindow = types.ListValueMust(t, vs) } +// GetRunAs returns the value of the RunAs field in EditPipeline_SdkV2 as +// a RunAs_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (o *EditPipeline_SdkV2) GetRunAs(ctx context.Context) (RunAs_SdkV2, bool) { + var e RunAs_SdkV2 + if o.RunAs.IsNull() || o.RunAs.IsUnknown() { + return e, false + } + var v []RunAs_SdkV2 + d := o.RunAs.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetRunAs sets the value of the RunAs field in EditPipeline_SdkV2. +func (o *EditPipeline_SdkV2) SetRunAs(ctx context.Context, v RunAs_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := o.Type(ctx).(basetypes.ObjectType).AttrTypes["run_as"] + o.RunAs = types.ListValueMust(t, vs) +} + // GetTrigger returns the value of the Trigger field in EditPipeline_SdkV2 as // a PipelineTrigger_SdkV2 value. // If the field is unknown or null, the boolean return value is false. @@ -5096,6 +5172,60 @@ func (o *RestartWindow_SdkV2) SetDaysOfWeek(ctx context.Context, v []types.Strin o.DaysOfWeek = types.ListValueMust(t, vs) } +// Write-only setting, available only in Create/Update calls. Specifies the user +// or service principal that the pipeline runs as. If not specified, the +// pipeline runs as the user who created the pipeline. +// +// Only `user_name` or `service_principal_name` can be specified. If both are +// specified, an error is thrown. +type RunAs_SdkV2 struct { + // Application ID of an active service principal. Setting this field + // requires the `servicePrincipal/user` role. + ServicePrincipalName types.String `tfsdk:"service_principal_name" tf:"optional"` + // The email of an active workspace user. Users can only set this field to + // their own email. + UserName types.String `tfsdk:"user_name" tf:"optional"` +} + +func (newState *RunAs_SdkV2) SyncEffectiveFieldsDuringCreateOrUpdate(plan RunAs_SdkV2) { +} + +func (newState *RunAs_SdkV2) SyncEffectiveFieldsDuringRead(existingState RunAs_SdkV2) { +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in RunAs. +// Container types (types.Map, types.List, types.Set) and object types (types.Object) do not carry +// the type information of their elements in the Go type system. This function provides a way to +// retrieve the type information of the elements in complex fields at runtime. The values of the map +// are the reflected types of the contained elements. They must be either primitive values from the +// plugin framework type system (types.String{}, types.Bool{}, types.Int64{}, types.Float64{}) or TF +// SDK values. +func (a RunAs_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{} +} + +// TFSDK types cannot implement the ObjectValuable interface directly, as it would otherwise +// interfere with how the plugin framework retrieves and sets values in state. Thus, RunAs_SdkV2 +// only implements ToObjectValue() and Type(). +func (o RunAs_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + o.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "service_principal_name": o.ServicePrincipalName, + "user_name": o.UserName, + }) +} + +// Type implements basetypes.ObjectValuable. +func (o RunAs_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "service_principal_name": types.StringType, + "user_name": types.StringType, + }, + } +} + type SchemaSpec_SdkV2 struct { // Required. Destination catalog to store tables. DestinationCatalog types.String `tfsdk:"destination_catalog" tf:"optional"` diff --git a/internal/service/pipelines_tf/model.go b/internal/service/pipelines_tf/model.go index 780d60e4f2..4e391c3d68 100755 --- a/internal/service/pipelines_tf/model.go +++ b/internal/service/pipelines_tf/model.go @@ -69,6 +69,13 @@ type CreatePipeline struct { Photon types.Bool `tfsdk:"photon" tf:"optional"` // Restart window of this pipeline. RestartWindow types.Object `tfsdk:"restart_window" tf:"optional,object"` + // Write-only setting, available only in Create/Update calls. Specifies the + // user or service principal that the pipeline runs as. If not specified, + // the pipeline runs as the user who created the pipeline. + // + // Only `user_name` or `service_principal_name` can be specified. If both + // are specified, an error is thrown. + RunAs types.Object `tfsdk:"run_as" tf:"optional,object"` // 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. @@ -109,6 +116,7 @@ func (a CreatePipeline) GetComplexFieldTypes(ctx context.Context) map[string]ref "libraries": reflect.TypeOf(PipelineLibrary{}), "notifications": reflect.TypeOf(Notifications{}), "restart_window": reflect.TypeOf(RestartWindow{}), + "run_as": reflect.TypeOf(RunAs{}), "trigger": reflect.TypeOf(PipelineTrigger{}), } } @@ -140,6 +148,7 @@ func (o CreatePipeline) ToObjectValue(ctx context.Context) basetypes.ObjectValue "notifications": o.Notifications, "photon": o.Photon, "restart_window": o.RestartWindow, + "run_as": o.RunAs, "schema": o.Schema, "serverless": o.Serverless, "storage": o.Storage, @@ -180,6 +189,7 @@ func (o CreatePipeline) Type(ctx context.Context) attr.Type { }, "photon": types.BoolType, "restart_window": RestartWindow{}.Type(ctx), + "run_as": RunAs{}.Type(ctx), "schema": types.StringType, "serverless": types.BoolType, "storage": types.StringType, @@ -433,6 +443,34 @@ func (o *CreatePipeline) SetRestartWindow(ctx context.Context, v RestartWindow) o.RestartWindow = vs } +// GetRunAs returns the value of the RunAs field in CreatePipeline as +// a RunAs value. +// If the field is unknown or null, the boolean return value is false. +func (o *CreatePipeline) GetRunAs(ctx context.Context) (RunAs, bool) { + var e RunAs + if o.RunAs.IsNull() || o.RunAs.IsUnknown() { + return e, false + } + var v []RunAs + d := o.RunAs.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetRunAs sets the value of the RunAs field in CreatePipeline. +func (o *CreatePipeline) SetRunAs(ctx context.Context, v RunAs) { + vs := v.ToObjectValue(ctx) + o.RunAs = vs +} + // GetTrigger returns the value of the Trigger field in CreatePipeline as // a PipelineTrigger value. // If the field is unknown or null, the boolean return value is false. @@ -758,6 +796,13 @@ type EditPipeline struct { PipelineId types.String `tfsdk:"pipeline_id" tf:"optional"` // Restart window of this pipeline. RestartWindow types.Object `tfsdk:"restart_window" tf:"optional,object"` + // Write-only setting, available only in Create/Update calls. Specifies the + // user or service principal that the pipeline runs as. If not specified, + // the pipeline runs as the user who created the pipeline. + // + // Only `user_name` or `service_principal_name` can be specified. If both + // are specified, an error is thrown. + RunAs types.Object `tfsdk:"run_as" tf:"optional,object"` // 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. @@ -798,6 +843,7 @@ func (a EditPipeline) GetComplexFieldTypes(ctx context.Context) map[string]refle "libraries": reflect.TypeOf(PipelineLibrary{}), "notifications": reflect.TypeOf(Notifications{}), "restart_window": reflect.TypeOf(RestartWindow{}), + "run_as": reflect.TypeOf(RunAs{}), "trigger": reflect.TypeOf(PipelineTrigger{}), } } @@ -830,6 +876,7 @@ func (o EditPipeline) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "photon": o.Photon, "pipeline_id": o.PipelineId, "restart_window": o.RestartWindow, + "run_as": o.RunAs, "schema": o.Schema, "serverless": o.Serverless, "storage": o.Storage, @@ -871,6 +918,7 @@ func (o EditPipeline) Type(ctx context.Context) attr.Type { "photon": types.BoolType, "pipeline_id": types.StringType, "restart_window": RestartWindow{}.Type(ctx), + "run_as": RunAs{}.Type(ctx), "schema": types.StringType, "serverless": types.BoolType, "storage": types.StringType, @@ -1124,6 +1172,34 @@ func (o *EditPipeline) SetRestartWindow(ctx context.Context, v RestartWindow) { o.RestartWindow = vs } +// GetRunAs returns the value of the RunAs field in EditPipeline as +// a RunAs value. +// If the field is unknown or null, the boolean return value is false. +func (o *EditPipeline) GetRunAs(ctx context.Context) (RunAs, bool) { + var e RunAs + if o.RunAs.IsNull() || o.RunAs.IsUnknown() { + return e, false + } + var v []RunAs + d := o.RunAs.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetRunAs sets the value of the RunAs field in EditPipeline. +func (o *EditPipeline) SetRunAs(ctx context.Context, v RunAs) { + vs := v.ToObjectValue(ctx) + o.RunAs = vs +} + // GetTrigger returns the value of the Trigger field in EditPipeline as // a PipelineTrigger value. // If the field is unknown or null, the boolean return value is false. @@ -5096,6 +5172,60 @@ func (o *RestartWindow) SetDaysOfWeek(ctx context.Context, v []types.String) { o.DaysOfWeek = types.ListValueMust(t, vs) } +// Write-only setting, available only in Create/Update calls. Specifies the user +// or service principal that the pipeline runs as. If not specified, the +// pipeline runs as the user who created the pipeline. +// +// Only `user_name` or `service_principal_name` can be specified. If both are +// specified, an error is thrown. +type RunAs struct { + // Application ID of an active service principal. Setting this field + // requires the `servicePrincipal/user` role. + ServicePrincipalName types.String `tfsdk:"service_principal_name" tf:"optional"` + // The email of an active workspace user. Users can only set this field to + // their own email. + UserName types.String `tfsdk:"user_name" tf:"optional"` +} + +func (newState *RunAs) SyncEffectiveFieldsDuringCreateOrUpdate(plan RunAs) { +} + +func (newState *RunAs) SyncEffectiveFieldsDuringRead(existingState RunAs) { +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in RunAs. +// Container types (types.Map, types.List, types.Set) and object types (types.Object) do not carry +// the type information of their elements in the Go type system. This function provides a way to +// retrieve the type information of the elements in complex fields at runtime. The values of the map +// are the reflected types of the contained elements. They must be either primitive values from the +// plugin framework type system (types.String{}, types.Bool{}, types.Int64{}, types.Float64{}) or TF +// SDK values. +func (a RunAs) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{} +} + +// TFSDK types cannot implement the ObjectValuable interface directly, as it would otherwise +// interfere with how the plugin framework retrieves and sets values in state. Thus, RunAs +// only implements ToObjectValue() and Type(). +func (o RunAs) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + o.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "service_principal_name": o.ServicePrincipalName, + "user_name": o.UserName, + }) +} + +// Type implements basetypes.ObjectValuable. +func (o RunAs) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "service_principal_name": types.StringType, + "user_name": types.StringType, + }, + } +} + type SchemaSpec struct { // Required. Destination catalog to store tables. DestinationCatalog types.String `tfsdk:"destination_catalog" tf:"optional"` diff --git a/internal/service/sharing_tf/legacy_model.go b/internal/service/sharing_tf/legacy_model.go index 6bbf36a8ea..66db41a6a1 100755 --- a/internal/service/sharing_tf/legacy_model.go +++ b/internal/service/sharing_tf/legacy_model.go @@ -2289,7 +2289,8 @@ type ShareInfo_SdkV2 struct { // A list of shared data objects within the share. Objects types.List `tfsdk:"object" tf:"optional"` // Username of current owner of share. - Owner types.String `tfsdk:"owner" tf:"computed"` + Owner types.String `tfsdk:"owner" tf:"optional"` + EffectiveOwner types.String `tfsdk:"effective_owner" tf:"computed"` // Storage Location URL (full path) for the share. StorageLocation types.String `tfsdk:"storage_location" tf:"optional"` // Storage root URL for the share. @@ -2301,9 +2302,15 @@ type ShareInfo_SdkV2 struct { } func (newState *ShareInfo_SdkV2) SyncEffectiveFieldsDuringCreateOrUpdate(plan ShareInfo_SdkV2) { + newState.EffectiveOwner = newState.Owner + newState.Owner = plan.Owner } func (newState *ShareInfo_SdkV2) SyncEffectiveFieldsDuringRead(existingState ShareInfo_SdkV2) { + newState.EffectiveOwner = existingState.EffectiveOwner + if existingState.EffectiveOwner.ValueString() == newState.Owner.ValueString() { + newState.Owner = existingState.Owner + } } // GetComplexFieldTypes returns a map of the types of elements in complex fields in ShareInfo. @@ -2332,6 +2339,7 @@ func (o ShareInfo_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValu "name": o.Name, "object": o.Objects, "owner": o.Owner, + "effective_owner": o.EffectiveOwner, "storage_location": o.StorageLocation, "storage_root": o.StorageRoot, "updated_at": o.UpdatedAt, @@ -2351,6 +2359,7 @@ func (o ShareInfo_SdkV2) Type(ctx context.Context) attr.Type { ElemType: SharedDataObject_SdkV2{}.Type(ctx), }, "owner": types.StringType, + "effective_owner": types.StringType, "storage_location": types.StringType, "storage_root": types.StringType, "updated_at": types.Int64Type, @@ -3040,7 +3049,8 @@ type UpdateShare_SdkV2 struct { // New name for the share. NewName types.String `tfsdk:"new_name" tf:"optional"` // Username of current owner of share. - Owner types.String `tfsdk:"owner" tf:"computed"` + Owner types.String `tfsdk:"owner" tf:"optional"` + EffectiveOwner types.String `tfsdk:"effective_owner" tf:"computed"` // Storage root URL for the share. StorageRoot types.String `tfsdk:"storage_root" tf:"optional"` // Array of shared data object updates. @@ -3048,9 +3058,15 @@ type UpdateShare_SdkV2 struct { } func (newState *UpdateShare_SdkV2) SyncEffectiveFieldsDuringCreateOrUpdate(plan UpdateShare_SdkV2) { + newState.EffectiveOwner = newState.Owner + newState.Owner = plan.Owner } func (newState *UpdateShare_SdkV2) SyncEffectiveFieldsDuringRead(existingState UpdateShare_SdkV2) { + newState.EffectiveOwner = existingState.EffectiveOwner + if existingState.EffectiveOwner.ValueString() == newState.Owner.ValueString() { + newState.Owner = existingState.Owner + } } // GetComplexFieldTypes returns a map of the types of elements in complex fields in UpdateShare. @@ -3073,12 +3089,13 @@ func (o UpdateShare_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectVa return types.ObjectValueMust( o.Type(ctx).(basetypes.ObjectType).AttrTypes, map[string]attr.Value{ - "comment": o.Comment, - "name": o.Name, - "new_name": o.NewName, - "owner": o.Owner, - "storage_root": o.StorageRoot, - "updates": o.Updates, + "comment": o.Comment, + "name": o.Name, + "new_name": o.NewName, + "owner": o.Owner, + "effective_owner": o.EffectiveOwner, + "storage_root": o.StorageRoot, + "updates": o.Updates, }) } @@ -3086,11 +3103,12 @@ func (o UpdateShare_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectVa func (o UpdateShare_SdkV2) Type(ctx context.Context) attr.Type { return types.ObjectType{ AttrTypes: map[string]attr.Type{ - "comment": types.StringType, - "name": types.StringType, - "new_name": types.StringType, - "owner": types.StringType, - "storage_root": types.StringType, + "comment": types.StringType, + "name": types.StringType, + "new_name": types.StringType, + "owner": types.StringType, + "effective_owner": types.StringType, + "storage_root": types.StringType, "updates": basetypes.ListType{ ElemType: SharedDataObjectUpdate_SdkV2{}.Type(ctx), }, diff --git a/internal/service/sharing_tf/model.go b/internal/service/sharing_tf/model.go index d1918325e2..e920f9ca0d 100755 --- a/internal/service/sharing_tf/model.go +++ b/internal/service/sharing_tf/model.go @@ -2289,7 +2289,8 @@ type ShareInfo struct { // A list of shared data objects within the share. Objects types.List `tfsdk:"object" tf:"optional"` // Username of current owner of share. - Owner types.String `tfsdk:"owner" tf:"computed"` + Owner types.String `tfsdk:"owner" tf:"optional"` + EffectiveOwner types.String `tfsdk:"effective_owner" tf:"computed"` // Storage Location URL (full path) for the share. StorageLocation types.String `tfsdk:"storage_location" tf:"optional"` // Storage root URL for the share. @@ -2301,9 +2302,15 @@ type ShareInfo struct { } func (newState *ShareInfo) SyncEffectiveFieldsDuringCreateOrUpdate(plan ShareInfo) { + newState.EffectiveOwner = newState.Owner + newState.Owner = plan.Owner } func (newState *ShareInfo) SyncEffectiveFieldsDuringRead(existingState ShareInfo) { + newState.EffectiveOwner = existingState.EffectiveOwner + if existingState.EffectiveOwner.ValueString() == newState.Owner.ValueString() { + newState.Owner = existingState.Owner + } } // GetComplexFieldTypes returns a map of the types of elements in complex fields in ShareInfo. @@ -2332,6 +2339,7 @@ func (o ShareInfo) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "name": o.Name, "object": o.Objects, "owner": o.Owner, + "effective_owner": o.EffectiveOwner, "storage_location": o.StorageLocation, "storage_root": o.StorageRoot, "updated_at": o.UpdatedAt, @@ -2351,6 +2359,7 @@ func (o ShareInfo) Type(ctx context.Context) attr.Type { ElemType: SharedDataObject{}.Type(ctx), }, "owner": types.StringType, + "effective_owner": types.StringType, "storage_location": types.StringType, "storage_root": types.StringType, "updated_at": types.Int64Type, @@ -3040,7 +3049,8 @@ type UpdateShare struct { // New name for the share. NewName types.String `tfsdk:"new_name" tf:"optional"` // Username of current owner of share. - Owner types.String `tfsdk:"owner" tf:"computed"` + Owner types.String `tfsdk:"owner" tf:"optional"` + EffectiveOwner types.String `tfsdk:"effective_owner" tf:"computed"` // Storage root URL for the share. StorageRoot types.String `tfsdk:"storage_root" tf:"optional"` // Array of shared data object updates. @@ -3048,9 +3058,15 @@ type UpdateShare struct { } func (newState *UpdateShare) SyncEffectiveFieldsDuringCreateOrUpdate(plan UpdateShare) { + newState.EffectiveOwner = newState.Owner + newState.Owner = plan.Owner } func (newState *UpdateShare) SyncEffectiveFieldsDuringRead(existingState UpdateShare) { + newState.EffectiveOwner = existingState.EffectiveOwner + if existingState.EffectiveOwner.ValueString() == newState.Owner.ValueString() { + newState.Owner = existingState.Owner + } } // GetComplexFieldTypes returns a map of the types of elements in complex fields in UpdateShare. @@ -3073,12 +3089,13 @@ func (o UpdateShare) ToObjectValue(ctx context.Context) basetypes.ObjectValue { return types.ObjectValueMust( o.Type(ctx).(basetypes.ObjectType).AttrTypes, map[string]attr.Value{ - "comment": o.Comment, - "name": o.Name, - "new_name": o.NewName, - "owner": o.Owner, - "storage_root": o.StorageRoot, - "updates": o.Updates, + "comment": o.Comment, + "name": o.Name, + "new_name": o.NewName, + "owner": o.Owner, + "effective_owner": o.EffectiveOwner, + "storage_root": o.StorageRoot, + "updates": o.Updates, }) } @@ -3086,11 +3103,12 @@ func (o UpdateShare) ToObjectValue(ctx context.Context) basetypes.ObjectValue { func (o UpdateShare) Type(ctx context.Context) attr.Type { return types.ObjectType{ AttrTypes: map[string]attr.Type{ - "comment": types.StringType, - "name": types.StringType, - "new_name": types.StringType, - "owner": types.StringType, - "storage_root": types.StringType, + "comment": types.StringType, + "name": types.StringType, + "new_name": types.StringType, + "owner": types.StringType, + "effective_owner": types.StringType, + "storage_root": types.StringType, "updates": basetypes.ListType{ ElemType: SharedDataObjectUpdate{}.Type(ctx), },