diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index 6854c7f284..57c80b78c2 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -e1ea3f5ba0bc5b53be94f56535a67ba701a52a52 \ No newline at end of file +c0e83a0de9da6aaad4cd6924fb65b1496bfdedcb \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index be4490556c..0d41ff5a4f 100755 --- a/.gitattributes +++ b/.gitattributes @@ -44,6 +44,12 @@ docs/data-sources/online_store.md linguist-generated=true docs/data-sources/online_stores.md linguist-generated=true docs/data-sources/policy_info.md linguist-generated=true docs/data-sources/policy_infos.md linguist-generated=true +docs/data-sources/postgres_branch.md linguist-generated=true +docs/data-sources/postgres_branches.md linguist-generated=true +docs/data-sources/postgres_endpoint.md linguist-generated=true +docs/data-sources/postgres_endpoints.md linguist-generated=true +docs/data-sources/postgres_project.md linguist-generated=true +docs/data-sources/postgres_projects.md linguist-generated=true docs/data-sources/quality_monitor_v2.md linguist-generated=true docs/data-sources/quality_monitors_v2.md linguist-generated=true docs/data-sources/rfa_access_request_destinations.md linguist-generated=true @@ -74,6 +80,9 @@ docs/resources/feature_engineering_materialized_feature.md linguist-generated=tr docs/resources/materialized_features_feature_tag.md linguist-generated=true docs/resources/online_store.md linguist-generated=true docs/resources/policy_info.md linguist-generated=true +docs/resources/postgres_branch.md linguist-generated=true +docs/resources/postgres_endpoint.md linguist-generated=true +docs/resources/postgres_project.md linguist-generated=true docs/resources/quality_monitor_v2.md linguist-generated=true docs/resources/rfa_access_request_destinations.md linguist-generated=true docs/resources/service_principal_federation_policy.md linguist-generated=true @@ -148,6 +157,15 @@ internal/providers/pluginfw/products/online_store/resource_online_store.go lingu internal/providers/pluginfw/products/policy_info/data_policy_info.go linguist-generated=true internal/providers/pluginfw/products/policy_info/data_policy_infos.go linguist-generated=true internal/providers/pluginfw/products/policy_info/resource_policy_info.go linguist-generated=true +internal/providers/pluginfw/products/postgres_branch/data_postgres_branch.go linguist-generated=true +internal/providers/pluginfw/products/postgres_branch/data_postgres_branches.go linguist-generated=true +internal/providers/pluginfw/products/postgres_branch/resource_postgres_branch.go linguist-generated=true +internal/providers/pluginfw/products/postgres_endpoint/data_postgres_endpoint.go linguist-generated=true +internal/providers/pluginfw/products/postgres_endpoint/data_postgres_endpoints.go linguist-generated=true +internal/providers/pluginfw/products/postgres_endpoint/resource_postgres_endpoint.go linguist-generated=true +internal/providers/pluginfw/products/postgres_project/data_postgres_project.go linguist-generated=true +internal/providers/pluginfw/products/postgres_project/data_postgres_projects.go linguist-generated=true +internal/providers/pluginfw/products/postgres_project/resource_postgres_project.go linguist-generated=true internal/providers/pluginfw/products/quality_monitor_v2/data_quality_monitor_v2.go linguist-generated=true internal/providers/pluginfw/products/quality_monitor_v2/data_quality_monitors_v2.go linguist-generated=true internal/providers/pluginfw/products/quality_monitor_v2/resource_quality_monitor_v2.go linguist-generated=true @@ -221,6 +239,8 @@ internal/service/oauth2_tf/legacy_model.go linguist-generated=true internal/service/oauth2_tf/model.go linguist-generated=true internal/service/pipelines_tf/legacy_model.go linguist-generated=true internal/service/pipelines_tf/model.go linguist-generated=true +internal/service/postgres_tf/legacy_model.go linguist-generated=true +internal/service/postgres_tf/model.go linguist-generated=true internal/service/provisioning_tf/legacy_model.go linguist-generated=true internal/service/provisioning_tf/model.go linguist-generated=true internal/service/qualitymonitorv2_tf/legacy_model.go linguist-generated=true diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index a5b68978fe..f26c88a045 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -5,6 +5,9 @@ ### Breaking Changes ### New Features and Improvements +* Add `databricks_postgres_branch` resource and data source ([#5286](https://github.com/databricks/terraform-provider-databricks/pull/5286)). +* Add `databricks_postgres_endpoint` resource and data source ([#5286](https://github.com/databricks/terraform-provider-databricks/pull/5286)). +* Add `databricks_postgres_project` resource and data source ([#5286](https://github.com/databricks/terraform-provider-databricks/pull/5286)). ### Bug Fixes @@ -13,3 +16,4 @@ ### Exporter ### Internal Changes +* Update Go SDK to v0.95.0. diff --git a/docs/data-sources/online_store.md b/docs/data-sources/online_store.md index 72c2f18388..92457a7706 100755 --- a/docs/data-sources/online_store.md +++ b/docs/data-sources/online_store.md @@ -20,4 +20,5 @@ The following attributes are exported: * `creator` (string) - The email of the creator of the online store * `name` (string) - The name of the online store. This is the unique identifier for the online store * `read_replica_count` (integer) - The number of read replicas for the online store. Defaults to 0 -* `state` (string) - The current state of the online store. Possible values are: `AVAILABLE`, `DELETING`, `FAILING_OVER`, `STARTING`, `STOPPED`, `UPDATING` \ No newline at end of file +* `state` (string) - The current state of the online store. Possible values are: `AVAILABLE`, `DELETING`, `FAILING_OVER`, `STARTING`, `STOPPED`, `UPDATING` +* `usage_policy_id` (string) - The usage policy applied to the online store to track billing \ No newline at end of file diff --git a/docs/data-sources/online_stores.md b/docs/data-sources/online_stores.md index 3539e4d893..f57a21ef06 100755 --- a/docs/data-sources/online_stores.md +++ b/docs/data-sources/online_stores.md @@ -21,4 +21,5 @@ This data source exports a single attribute, `online_stores`. It is a list of re * `creator` (string) - The email of the creator of the online store * `name` (string) - The name of the online store. This is the unique identifier for the online store * `read_replica_count` (integer) - The number of read replicas for the online store. Defaults to 0 -* `state` (string) - The current state of the online store. Possible values are: `AVAILABLE`, `DELETING`, `FAILING_OVER`, `STARTING`, `STOPPED`, `UPDATING` \ No newline at end of file +* `state` (string) - The current state of the online store. Possible values are: `AVAILABLE`, `DELETING`, `FAILING_OVER`, `STARTING`, `STOPPED`, `UPDATING` +* `usage_policy_id` (string) - The usage policy applied to the online store to track billing \ No newline at end of file diff --git a/docs/data-sources/postgres_branch.md b/docs/data-sources/postgres_branch.md new file mode 100755 index 0000000000..78bc56705c --- /dev/null +++ b/docs/data-sources/postgres_branch.md @@ -0,0 +1,42 @@ +--- +subcategory: "Postgres" +--- +# databricks_postgres_branch Data Source +[![Private Preview](https://img.shields.io/badge/Release_Stage-Private_Preview-blueviolet)](https://docs.databricks.com/aws/en/release-notes/release-types) + + + +## Example Usage + + +## Arguments +The following arguments are supported: +* `name` (string, required) - The resource name of the branch. + Format: projects/{project_id}/branches/{branch_id} + +## Attributes +The following attributes are exported: +* `create_time` (string) - A timestamp indicating when the branch was created +* `current_state` (string) - The branch's state, indicating if it is initializing, ready for use, or archived. Possible values are: `ARCHIVED`, `IMPORTING`, `INIT`, `READY`, `RESETTING` +* `default` (boolean) - Whether the branch is the project's default branch. This field is only returned on create/update responses. + See effective_default for the value that is actually applied to the branch +* `effective_default` (boolean) - Whether the branch is the project's default branch +* `effective_is_protected` (boolean) - Whether the branch is protected +* `effective_source_branch` (string) - The name of the source branch from which this branch was created. + Format: projects/{project_id}/branches/{branch_id} +* `effective_source_branch_lsn` (string) - The Log Sequence Number (LSN) on the source branch from which this branch was created +* `effective_source_branch_time` (string) - The point in time on the source branch from which this branch was created +* `is_protected` (boolean) - Whether the branch is protected +* `logical_size_bytes` (integer) - The logical size of the branch +* `name` (string) - The resource name of the branch. + Format: projects/{project_id}/branches/{branch_id} +* `parent` (string) - The project containing this branch. + Format: projects/{project_id} +* `pending_state` (string) - The pending state of the branch, if a state transition is in progress. Possible values are: `ARCHIVED`, `IMPORTING`, `INIT`, `READY`, `RESETTING` +* `source_branch` (string) - The name of the source branch from which this branch was created. + Format: projects/{project_id}/branches/{branch_id} +* `source_branch_lsn` (string) - The Log Sequence Number (LSN) on the source branch from which this branch was created +* `source_branch_time` (string) - The point in time on the source branch from which this branch was created +* `state_change_time` (string) - A timestamp indicating when the `current_state` began +* `uid` (string) - System generated unique ID for the branch +* `update_time` (string) - A timestamp indicating when the branch was last updated \ No newline at end of file diff --git a/docs/data-sources/postgres_branches.md b/docs/data-sources/postgres_branches.md new file mode 100755 index 0000000000..998da0fed0 --- /dev/null +++ b/docs/data-sources/postgres_branches.md @@ -0,0 +1,44 @@ +--- +subcategory: "Postgres" +--- +# databricks_postgres_branches Data Source +[![Private Preview](https://img.shields.io/badge/Release_Stage-Private_Preview-blueviolet)](https://docs.databricks.com/aws/en/release-notes/release-types) + + + +## Example Usage + + +## Arguments +The following arguments are supported: +* `parent` (string, required) - The Project that owns this collection of branches. + Format: projects/{project_id} +* `page_size` (integer, optional) - Upper bound for items returned + + +## Attributes +This data source exports a single attribute, `branches`. It is a list of resources, each with the following attributes: +* `create_time` (string) - A timestamp indicating when the branch was created +* `current_state` (string) - The branch's state, indicating if it is initializing, ready for use, or archived. Possible values are: `ARCHIVED`, `IMPORTING`, `INIT`, `READY`, `RESETTING` +* `default` (boolean) - Whether the branch is the project's default branch. This field is only returned on create/update responses. + See effective_default for the value that is actually applied to the branch +* `effective_default` (boolean) - Whether the branch is the project's default branch +* `effective_is_protected` (boolean) - Whether the branch is protected +* `effective_source_branch` (string) - The name of the source branch from which this branch was created. + Format: projects/{project_id}/branches/{branch_id} +* `effective_source_branch_lsn` (string) - The Log Sequence Number (LSN) on the source branch from which this branch was created +* `effective_source_branch_time` (string) - The point in time on the source branch from which this branch was created +* `is_protected` (boolean) - Whether the branch is protected +* `logical_size_bytes` (integer) - The logical size of the branch +* `name` (string) - The resource name of the branch. + Format: projects/{project_id}/branches/{branch_id} +* `parent` (string) - The project containing this branch. + Format: projects/{project_id} +* `pending_state` (string) - The pending state of the branch, if a state transition is in progress. Possible values are: `ARCHIVED`, `IMPORTING`, `INIT`, `READY`, `RESETTING` +* `source_branch` (string) - The name of the source branch from which this branch was created. + Format: projects/{project_id}/branches/{branch_id} +* `source_branch_lsn` (string) - The Log Sequence Number (LSN) on the source branch from which this branch was created +* `source_branch_time` (string) - The point in time on the source branch from which this branch was created +* `state_change_time` (string) - A timestamp indicating when the `current_state` began +* `uid` (string) - System generated unique ID for the branch +* `update_time` (string) - A timestamp indicating when the branch was last updated \ No newline at end of file diff --git a/docs/data-sources/postgres_endpoint.md b/docs/data-sources/postgres_endpoint.md new file mode 100755 index 0000000000..cb158e5d40 --- /dev/null +++ b/docs/data-sources/postgres_endpoint.md @@ -0,0 +1,54 @@ +--- +subcategory: "Postgres" +--- +# databricks_postgres_endpoint Data Source +[![Private Preview](https://img.shields.io/badge/Release_Stage-Private_Preview-blueviolet)](https://docs.databricks.com/aws/en/release-notes/release-types) + + + +## Example Usage + + +## Arguments +The following arguments are supported: +* `name` (string, required) - The resource name of the endpoint. + Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + +## Attributes +The following attributes are exported: +* `autoscaling_limit_max_cu` (number) - The maximum number of Compute Units +* `autoscaling_limit_min_cu` (number) - The minimum number of Compute Units +* `create_time` (string) - A timestamp indicating when the compute endpoint was created +* `current_state` (string) - Possible values are: `ACTIVE`, `IDLE`, `INIT` +* `disabled` (boolean) - Whether to restrict connections to the compute endpoint. + Enabling this option schedules a suspend compute operation. + A disabled compute endpoint cannot be enabled by a connection or + console action +* `effective_autoscaling_limit_max_cu` (number) - The maximum number of Compute Units +* `effective_autoscaling_limit_min_cu` (number) - The minimum number of Compute Units +* `effective_disabled` (boolean) - Whether to restrict connections to the compute endpoint. + Enabling this option schedules a suspend compute operation. + A disabled compute endpoint cannot be enabled by a connection or + console action +* `effective_pooler_mode` (string) - Possible values are: `TRANSACTION` +* `effective_settings` (EndpointSettings) +* `effective_suspend_timeout_duration` (string) - Duration of inactivity after which the compute endpoint is automatically suspended +* `endpoint_type` (string) - The endpoint type. There could be only one READ_WRITE endpoint per branch. Possible values are: `READ_ONLY`, `READ_WRITE` +* `host` (string) - The hostname of the compute endpoint. This is the hostname specified when connecting to a database +* `last_active_time` (string) - A timestamp indicating when the compute endpoint was last active +* `name` (string) - The resource name of the endpoint. + Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} +* `parent` (string) - The branch containing this endpoint. + Format: projects/{project_id}/branches/{branch_id} +* `pending_state` (string) - Possible values are: `ACTIVE`, `IDLE`, `INIT` +* `pooler_mode` (string) - Possible values are: `TRANSACTION` +* `settings` (EndpointSettings) +* `start_time` (string) - A timestamp indicating when the compute endpoint was last started +* `suspend_time` (string) - A timestamp indicating when the compute endpoint was last suspended +* `suspend_timeout_duration` (string) - Duration of inactivity after which the compute endpoint is automatically suspended +* `uid` (string) - System generated unique ID for the endpoint +* `update_time` (string) - A timestamp indicating when the compute endpoint was last updated + +### EndpointSettings +* `pg_settings` (object) - A raw representation of Postgres settings +* `pgbouncer_settings` (object) - A raw representation of PgBouncer settings \ No newline at end of file diff --git a/docs/data-sources/postgres_endpoints.md b/docs/data-sources/postgres_endpoints.md new file mode 100755 index 0000000000..a9bfa604f1 --- /dev/null +++ b/docs/data-sources/postgres_endpoints.md @@ -0,0 +1,56 @@ +--- +subcategory: "Postgres" +--- +# databricks_postgres_endpoints Data Source +[![Private Preview](https://img.shields.io/badge/Release_Stage-Private_Preview-blueviolet)](https://docs.databricks.com/aws/en/release-notes/release-types) + + + +## Example Usage + + +## Arguments +The following arguments are supported: +* `parent` (string, required) - The Branch that owns this collection of endpoints. + Format: projects/{project_id}/branches/{branch_id} +* `page_size` (integer, optional) - Upper bound for items returned + + +## Attributes +This data source exports a single attribute, `endpoints`. It is a list of resources, each with the following attributes: +* `autoscaling_limit_max_cu` (number) - The maximum number of Compute Units +* `autoscaling_limit_min_cu` (number) - The minimum number of Compute Units +* `create_time` (string) - A timestamp indicating when the compute endpoint was created +* `current_state` (string) - Possible values are: `ACTIVE`, `IDLE`, `INIT` +* `disabled` (boolean) - Whether to restrict connections to the compute endpoint. + Enabling this option schedules a suspend compute operation. + A disabled compute endpoint cannot be enabled by a connection or + console action +* `effective_autoscaling_limit_max_cu` (number) - The maximum number of Compute Units +* `effective_autoscaling_limit_min_cu` (number) - The minimum number of Compute Units +* `effective_disabled` (boolean) - Whether to restrict connections to the compute endpoint. + Enabling this option schedules a suspend compute operation. + A disabled compute endpoint cannot be enabled by a connection or + console action +* `effective_pooler_mode` (string) - Possible values are: `TRANSACTION` +* `effective_settings` (EndpointSettings) +* `effective_suspend_timeout_duration` (string) - Duration of inactivity after which the compute endpoint is automatically suspended +* `endpoint_type` (string) - The endpoint type. There could be only one READ_WRITE endpoint per branch. Possible values are: `READ_ONLY`, `READ_WRITE` +* `host` (string) - The hostname of the compute endpoint. This is the hostname specified when connecting to a database +* `last_active_time` (string) - A timestamp indicating when the compute endpoint was last active +* `name` (string) - The resource name of the endpoint. + Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} +* `parent` (string) - The branch containing this endpoint. + Format: projects/{project_id}/branches/{branch_id} +* `pending_state` (string) - Possible values are: `ACTIVE`, `IDLE`, `INIT` +* `pooler_mode` (string) - Possible values are: `TRANSACTION` +* `settings` (EndpointSettings) +* `start_time` (string) - A timestamp indicating when the compute endpoint was last started +* `suspend_time` (string) - A timestamp indicating when the compute endpoint was last suspended +* `suspend_timeout_duration` (string) - Duration of inactivity after which the compute endpoint is automatically suspended +* `uid` (string) - System generated unique ID for the endpoint +* `update_time` (string) - A timestamp indicating when the compute endpoint was last updated + +### EndpointSettings +* `pg_settings` (object) - A raw representation of Postgres settings +* `pgbouncer_settings` (object) - A raw representation of PgBouncer settings \ No newline at end of file diff --git a/docs/data-sources/postgres_project.md b/docs/data-sources/postgres_project.md new file mode 100755 index 0000000000..b6623d1e26 --- /dev/null +++ b/docs/data-sources/postgres_project.md @@ -0,0 +1,48 @@ +--- +subcategory: "Postgres" +--- +# databricks_postgres_project Data Source +[![Private Preview](https://img.shields.io/badge/Release_Stage-Private_Preview-blueviolet)](https://docs.databricks.com/aws/en/release-notes/release-types) + + + +## Example Usage + + +## Arguments +The following arguments are supported: +* `name` (string, required) - The resource name of the project. + Format: projects/{project_id} + +## Attributes +The following attributes are exported: +* `branch_logical_size_limit_bytes` (integer) - The logical size limit for a branch +* `compute_last_active_time` (string) - The most recent time when any endpoint of this project was active +* `create_time` (string) - A timestamp indicating when the project was created +* `default_endpoint_settings` (ProjectDefaultEndpointSettings) +* `display_name` (string) - Human-readable project name +* `effective_default_endpoint_settings` (ProjectDefaultEndpointSettings) +* `effective_display_name` (string) +* `effective_history_retention_duration` (string) +* `effective_pg_version` (integer) +* `effective_settings` (ProjectSettings) +* `history_retention_duration` (string) - The number of seconds to retain the shared history for point in time recovery for all branches in this project +* `name` (string) - The resource name of the project. + Format: projects/{project_id} +* `pg_version` (integer) - The major Postgres version number +* `settings` (ProjectSettings) +* `synthetic_storage_size_bytes` (integer) - The current space occupied by the project in storage. Synthetic storage size combines the logical data size and Write-Ahead Log (WAL) size for all branches in a project +* `uid` (string) - System generated unique ID for the project +* `update_time` (string) - A timestamp indicating when the project was last updated + +### ProjectDefaultEndpointSettings +* `autoscaling_limit_max_cu` (number) - The maximum number of Compute Units +* `autoscaling_limit_min_cu` (number) - The minimum number of Compute Units +* `pg_settings` (object) - A raw representation of Postgres settings +* `pgbouncer_settings` (object) - A raw representation of PgBouncer settings +* `suspend_timeout_duration` (string) - Duration of inactivity after which the compute endpoint is automatically suspended + +### ProjectSettings +* `enable_logical_replication` (boolean) - Sets wal_level=logical for all compute endpoints in this project. + All active endpoints will be suspended. + Once enabled, logical replication cannot be disabled \ No newline at end of file diff --git a/docs/data-sources/postgres_projects.md b/docs/data-sources/postgres_projects.md new file mode 100755 index 0000000000..c077e06fcf --- /dev/null +++ b/docs/data-sources/postgres_projects.md @@ -0,0 +1,48 @@ +--- +subcategory: "Postgres" +--- +# databricks_postgres_projects Data Source +[![Private Preview](https://img.shields.io/badge/Release_Stage-Private_Preview-blueviolet)](https://docs.databricks.com/aws/en/release-notes/release-types) + + + +## Example Usage + + +## Arguments +The following arguments are supported: +* `page_size` (integer, optional) - Upper bound for items returned + + +## Attributes +This data source exports a single attribute, `projects`. It is a list of resources, each with the following attributes: +* `branch_logical_size_limit_bytes` (integer) - The logical size limit for a branch +* `compute_last_active_time` (string) - The most recent time when any endpoint of this project was active +* `create_time` (string) - A timestamp indicating when the project was created +* `default_endpoint_settings` (ProjectDefaultEndpointSettings) +* `display_name` (string) - Human-readable project name +* `effective_default_endpoint_settings` (ProjectDefaultEndpointSettings) +* `effective_display_name` (string) +* `effective_history_retention_duration` (string) +* `effective_pg_version` (integer) +* `effective_settings` (ProjectSettings) +* `history_retention_duration` (string) - The number of seconds to retain the shared history for point in time recovery for all branches in this project +* `name` (string) - The resource name of the project. + Format: projects/{project_id} +* `pg_version` (integer) - The major Postgres version number +* `settings` (ProjectSettings) +* `synthetic_storage_size_bytes` (integer) - The current space occupied by the project in storage. Synthetic storage size combines the logical data size and Write-Ahead Log (WAL) size for all branches in a project +* `uid` (string) - System generated unique ID for the project +* `update_time` (string) - A timestamp indicating when the project was last updated + +### ProjectDefaultEndpointSettings +* `autoscaling_limit_max_cu` (number) - The maximum number of Compute Units +* `autoscaling_limit_min_cu` (number) - The minimum number of Compute Units +* `pg_settings` (object) - A raw representation of Postgres settings +* `pgbouncer_settings` (object) - A raw representation of PgBouncer settings +* `suspend_timeout_duration` (string) - Duration of inactivity after which the compute endpoint is automatically suspended + +### ProjectSettings +* `enable_logical_replication` (boolean) - Sets wal_level=logical for all compute endpoints in this project. + All active endpoints will be suspended. + Once enabled, logical replication cannot be disabled \ No newline at end of file diff --git a/docs/data-sources/tag_policies.md b/docs/data-sources/tag_policies.md index 9e088bf4c7..c18dc951fc 100755 --- a/docs/data-sources/tag_policies.md +++ b/docs/data-sources/tag_policies.md @@ -4,7 +4,14 @@ subcategory: "Tags" # databricks_tag_policies Data Source [![Public Preview](https://img.shields.io/badge/Release_Stage-Public_Preview-yellowgreen)](https://docs.databricks.com/aws/en/release-notes/release-types) -This data source can be used to list all tag policies in the account. Manage tag policy permissions using the `databricks_access_control_rule_set` resource. +This data source can be used to list all tag policies in the account. + +The following resources are often used in the same context: + +* [databricks_entity_tag_assignment](../resources/entity_tag_assignment.md) for assigning tags to supported Unity Catalog entities. +* [databricks_workspace_entity_tag_assignment](../resources/workspace_entity_tag_assignment.md) for assigning tags to supported workspace entities. +* [databricks_policy_info](../resources/policy_info.md) for defining ABAC policies using governed tags. +* [databricks_access_control_rule_set](../resources/access_control_rule_set.md) for managing account-level and individual tag policy permissions. -> **Note** This resource can only be used with a workspace-level provider! diff --git a/docs/data-sources/tag_policy.md b/docs/data-sources/tag_policy.md index 3426543a24..fe3df712bf 100755 --- a/docs/data-sources/tag_policy.md +++ b/docs/data-sources/tag_policy.md @@ -4,7 +4,14 @@ subcategory: "Tags" # databricks_tag_policy Data Source [![Public Preview](https://img.shields.io/badge/Release_Stage-Public_Preview-yellowgreen)](https://docs.databricks.com/aws/en/release-notes/release-types) -This data source can be used to get a single tag policy by its tag key. Manage tag policy permissions using the `databricks_access_control_rule_set` resource. +This data source can be used to get a single tag policy by its tag key. + +The following resources are often used in the same context: + +* [databricks_entity_tag_assignment](../resources/entity_tag_assignment.md) for assigning tags to supported Unity Catalog entities. +* [databricks_workspace_entity_tag_assignment](../resources/workspace_entity_tag_assignment.md) for assigning tags to supported workspace entities. +* [databricks_policy_info](../resources/policy_info.md) for defining ABAC policies using governed tags. +* [databricks_access_control_rule_set](../resources/access_control_rule_set.md) for managing account-level and individual tag policy permissions. -> **Note** This resource can only be used with a workspace-level provider! diff --git a/docs/resources/online_store.md b/docs/resources/online_store.md index 14db0fdd41..68e84d6159 100755 --- a/docs/resources/online_store.md +++ b/docs/resources/online_store.md @@ -14,6 +14,7 @@ The following arguments are supported: * `capacity` (string, required) - The capacity of the online store. Valid values are "CU_1", "CU_2", "CU_4", "CU_8" * `name` (string, required) - The name of the online store. This is the unique identifier for the online store * `read_replica_count` (integer, optional) - The number of read replicas for the online store. Defaults to 0 +* `usage_policy_id` (string, optional) - The usage policy applied to the online store to track billing ## Attributes In addition to the above arguments, the following attributes are exported: diff --git a/docs/resources/postgres_branch.md b/docs/resources/postgres_branch.md new file mode 100755 index 0000000000..aed105fb88 --- /dev/null +++ b/docs/resources/postgres_branch.md @@ -0,0 +1,58 @@ +--- +subcategory: "Postgres" +--- +# databricks_postgres_branch Resource +[![Private Preview](https://img.shields.io/badge/Release_Stage-Private_Preview-blueviolet)](https://docs.databricks.com/aws/en/release-notes/release-types) + + + +## Example Usage + + +## Arguments +The following arguments are supported: +* `parent` (string, required) - The project containing this branch. + Format: projects/{project_id} +* `branch_id` (string, optional) - The ID to use for the Branch, which will become the final component of + the branch's resource name. + + This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/ +* `default` (boolean, optional) - Whether the branch is the project's default branch. This field is only returned on create/update responses. + See effective_default for the value that is actually applied to the branch +* `is_protected` (boolean, optional) - Whether the branch is protected +* `source_branch` (string, optional) - The name of the source branch from which this branch was created. + Format: projects/{project_id}/branches/{branch_id} +* `source_branch_lsn` (string, optional) - The Log Sequence Number (LSN) on the source branch from which this branch was created +* `source_branch_time` (string, optional) - The point in time on the source branch from which this branch was created + +## Attributes +In addition to the above arguments, the following attributes are exported: +* `create_time` (string) - A timestamp indicating when the branch was created +* `current_state` (string) - The branch's state, indicating if it is initializing, ready for use, or archived. Possible values are: `ARCHIVED`, `IMPORTING`, `INIT`, `READY`, `RESETTING` +* `effective_default` (boolean) - Whether the branch is the project's default branch +* `effective_is_protected` (boolean) - Whether the branch is protected +* `effective_source_branch` (string) - The name of the source branch from which this branch was created. + Format: projects/{project_id}/branches/{branch_id} +* `effective_source_branch_lsn` (string) - The Log Sequence Number (LSN) on the source branch from which this branch was created +* `effective_source_branch_time` (string) - The point in time on the source branch from which this branch was created +* `logical_size_bytes` (integer) - The logical size of the branch +* `name` (string) - The resource name of the branch. + Format: projects/{project_id}/branches/{branch_id} +* `pending_state` (string) - The pending state of the branch, if a state transition is in progress. Possible values are: `ARCHIVED`, `IMPORTING`, `INIT`, `READY`, `RESETTING` +* `state_change_time` (string) - A timestamp indicating when the `current_state` began +* `uid` (string) - System generated unique ID for the branch +* `update_time` (string) - A timestamp indicating when the branch was last updated + +## Import +As of Terraform v1.5, resources can be imported through configuration. +```hcl +import { + id = "name" + to = databricks_postgres_branch.this +} +``` + +If you are using an older version of Terraform, import the resource using the `terraform import` command as follows: +```sh +terraform import databricks_postgres_branch.this "name" +``` \ No newline at end of file diff --git a/docs/resources/postgres_endpoint.md b/docs/resources/postgres_endpoint.md new file mode 100755 index 0000000000..80e3f5a148 --- /dev/null +++ b/docs/resources/postgres_endpoint.md @@ -0,0 +1,70 @@ +--- +subcategory: "Postgres" +--- +# databricks_postgres_endpoint Resource +[![Private Preview](https://img.shields.io/badge/Release_Stage-Private_Preview-blueviolet)](https://docs.databricks.com/aws/en/release-notes/release-types) + + + +## Example Usage + + +## Arguments +The following arguments are supported: +* `endpoint_type` (string, required) - The endpoint type. There could be only one READ_WRITE endpoint per branch. Possible values are: `READ_ONLY`, `READ_WRITE` +* `parent` (string, required) - The branch containing this endpoint. + Format: projects/{project_id}/branches/{branch_id} +* `autoscaling_limit_max_cu` (number, optional) - The maximum number of Compute Units +* `autoscaling_limit_min_cu` (number, optional) - The minimum number of Compute Units +* `disabled` (boolean, optional) - Whether to restrict connections to the compute endpoint. + Enabling this option schedules a suspend compute operation. + A disabled compute endpoint cannot be enabled by a connection or + console action +* `endpoint_id` (string, optional) - The ID to use for the Endpoint, which will become the final component of + the endpoint's resource name. + + This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/ +* `pooler_mode` (string, optional) - Possible values are: `TRANSACTION` +* `settings` (EndpointSettings, optional) +* `suspend_timeout_duration` (string, optional) - Duration of inactivity after which the compute endpoint is automatically suspended + +### EndpointSettings +* `pg_settings` (object, optional) - A raw representation of Postgres settings +* `pgbouncer_settings` (object, optional) - A raw representation of PgBouncer settings + +## Attributes +In addition to the above arguments, the following attributes are exported: +* `create_time` (string) - A timestamp indicating when the compute endpoint was created +* `current_state` (string) - Possible values are: `ACTIVE`, `IDLE`, `INIT` +* `effective_autoscaling_limit_max_cu` (number) - The maximum number of Compute Units +* `effective_autoscaling_limit_min_cu` (number) - The minimum number of Compute Units +* `effective_disabled` (boolean) - Whether to restrict connections to the compute endpoint. + Enabling this option schedules a suspend compute operation. + A disabled compute endpoint cannot be enabled by a connection or + console action +* `effective_pooler_mode` (string) - Possible values are: `TRANSACTION` +* `effective_settings` (EndpointSettings) +* `effective_suspend_timeout_duration` (string) - Duration of inactivity after which the compute endpoint is automatically suspended +* `host` (string) - The hostname of the compute endpoint. This is the hostname specified when connecting to a database +* `last_active_time` (string) - A timestamp indicating when the compute endpoint was last active +* `name` (string) - The resource name of the endpoint. + Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} +* `pending_state` (string) - Possible values are: `ACTIVE`, `IDLE`, `INIT` +* `start_time` (string) - A timestamp indicating when the compute endpoint was last started +* `suspend_time` (string) - A timestamp indicating when the compute endpoint was last suspended +* `uid` (string) - System generated unique ID for the endpoint +* `update_time` (string) - A timestamp indicating when the compute endpoint was last updated + +## Import +As of Terraform v1.5, resources can be imported through configuration. +```hcl +import { + id = "name" + to = databricks_postgres_endpoint.this +} +``` + +If you are using an older version of Terraform, import the resource using the `terraform import` command as follows: +```sh +terraform import databricks_postgres_endpoint.this "name" +``` \ No newline at end of file diff --git a/docs/resources/postgres_project.md b/docs/resources/postgres_project.md new file mode 100755 index 0000000000..46b24f8d6a --- /dev/null +++ b/docs/resources/postgres_project.md @@ -0,0 +1,64 @@ +--- +subcategory: "Postgres" +--- +# databricks_postgres_project Resource +[![Private Preview](https://img.shields.io/badge/Release_Stage-Private_Preview-blueviolet)](https://docs.databricks.com/aws/en/release-notes/release-types) + + + +## Example Usage + + +## Arguments +The following arguments are supported: +* `default_endpoint_settings` (ProjectDefaultEndpointSettings, optional) +* `display_name` (string, optional) - Human-readable project name +* `history_retention_duration` (string, optional) - The number of seconds to retain the shared history for point in time recovery for all branches in this project +* `pg_version` (integer, optional) - The major Postgres version number +* `project_id` (string, optional) - The ID to use for the Project, which will become the final component of + the project's resource name. + + This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/ +* `settings` (ProjectSettings, optional) + +### ProjectDefaultEndpointSettings +* `autoscaling_limit_max_cu` (number, optional) - The maximum number of Compute Units +* `autoscaling_limit_min_cu` (number, optional) - The minimum number of Compute Units +* `pg_settings` (object, optional) - A raw representation of Postgres settings +* `pgbouncer_settings` (object, optional) - A raw representation of PgBouncer settings +* `suspend_timeout_duration` (string, optional) - Duration of inactivity after which the compute endpoint is automatically suspended + +### ProjectSettings +* `enable_logical_replication` (boolean, optional) - Sets wal_level=logical for all compute endpoints in this project. + All active endpoints will be suspended. + Once enabled, logical replication cannot be disabled + +## Attributes +In addition to the above arguments, the following attributes are exported: +* `branch_logical_size_limit_bytes` (integer) - The logical size limit for a branch +* `compute_last_active_time` (string) - The most recent time when any endpoint of this project was active +* `create_time` (string) - A timestamp indicating when the project was created +* `effective_default_endpoint_settings` (ProjectDefaultEndpointSettings) +* `effective_display_name` (string) +* `effective_history_retention_duration` (string) +* `effective_pg_version` (integer) +* `effective_settings` (ProjectSettings) +* `name` (string) - The resource name of the project. + Format: projects/{project_id} +* `synthetic_storage_size_bytes` (integer) - The current space occupied by the project in storage. Synthetic storage size combines the logical data size and Write-Ahead Log (WAL) size for all branches in a project +* `uid` (string) - System generated unique ID for the project +* `update_time` (string) - A timestamp indicating when the project was last updated + +## Import +As of Terraform v1.5, resources can be imported through configuration. +```hcl +import { + id = "name" + to = databricks_postgres_project.this +} +``` + +If you are using an older version of Terraform, import the resource using the `terraform import` command as follows: +```sh +terraform import databricks_postgres_project.this "name" +``` \ No newline at end of file diff --git a/docs/resources/tag_policy.md b/docs/resources/tag_policy.md index 0ef0d05f8e..9798e7348b 100755 --- a/docs/resources/tag_policy.md +++ b/docs/resources/tag_policy.md @@ -4,7 +4,14 @@ subcategory: "Tags" # databricks_tag_policy Resource [![Public Preview](https://img.shields.io/badge/Release_Stage-Public_Preview-yellowgreen)](https://docs.databricks.com/aws/en/release-notes/release-types) -Define tag policies to manage governed tags in your account. Manage tag policy permissions using the `databricks_access_control_rule_set` resource. +Define tag policies to manage governed tags in your account. + +The following resources are often used in the same context: + +* [databricks_entity_tag_assignment](entity_tag_assignment.md) for assigning tags to supported Unity Catalog entities. +* [databricks_workspace_entity_tag_assignment](workspace_entity_tag_assignment.md) for assigning tags to supported workspace entities. +* [databricks_policy_info](policy_info.md) for defining ABAC policies using governed tags. +* [databricks_access_control_rule_set](access_control_rule_set.md) for managing account-level and individual tag policy permissions. -> **Note** This resource can only be used with a workspace-level provider! diff --git a/go.mod b/go.mod index 6efbb3dd60..c18ac6cc61 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/databricks/terraform-provider-databricks go 1.24.0 require ( - github.com/databricks/databricks-sdk-go v0.94.0 + github.com/databricks/databricks-sdk-go v0.95.0 github.com/golang-jwt/jwt/v4 v4.5.2 github.com/hashicorp/go-cty v1.5.0 github.com/hashicorp/hcl v1.0.0 diff --git a/go.sum b/go.sum index 3abadaef8d..1adece6d14 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= -github.com/databricks/databricks-sdk-go v0.94.0 h1:+ITzL/O6/8FkHBJ4oWj1o8PkZ9GPozqydpXJRjsdxzw= -github.com/databricks/databricks-sdk-go v0.94.0/go.mod h1:hWoHnHbNLjPKiTm5K/7bcIv3J3Pkgo5x9pPzh8K3RVE= +github.com/databricks/databricks-sdk-go v0.95.0 h1:ZehbIygQgK3yeKEJIiichtftwPmiYVb4SrqBukJGbFU= +github.com/databricks/databricks-sdk-go v0.95.0/go.mod h1:hWoHnHbNLjPKiTm5K/7bcIv3J3Pkgo5x9pPzh8K3RVE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= diff --git a/internal/providers/pluginfw/auto_generation.go b/internal/providers/pluginfw/auto_generation.go index 161e03392c..6c7f022e07 100644 --- a/internal/providers/pluginfw/auto_generation.go +++ b/internal/providers/pluginfw/auto_generation.go @@ -41,6 +41,12 @@ import ( "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/products/policy_info" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/products/postgres_branch" + + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/products/postgres_endpoint" + + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/products/postgres_project" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/products/quality_monitor_v2" "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/products/rfa_access_request_destinations" @@ -80,6 +86,9 @@ var autoGeneratedResources = []func() resource.Resource{ materialized_features_feature_tag.ResourceFeatureTag, online_store.ResourceOnlineStore, policy_info.ResourcePolicyInfo, + postgres_branch.ResourceBranch, + postgres_endpoint.ResourceEndpoint, + postgres_project.ResourceProject, quality_monitor_v2.ResourceQualityMonitor, rfa_access_request_destinations.ResourceAccessRequestDestination, service_principal_federation_policy.ResourceFederationPolicy, @@ -110,6 +119,9 @@ var autoGeneratedDataSources = []func() datasource.DataSource{ materialized_features_feature_tag.DataSourceFeatureTag, online_store.DataSourceOnlineStore, policy_info.DataSourcePolicyInfo, + postgres_branch.DataSourceBranch, + postgres_endpoint.DataSourceEndpoint, + postgres_project.DataSourceProject, quality_monitor_v2.DataSourceQualityMonitor, rfa_access_request_destinations.DataSourceAccessRequestDestination, service_principal_federation_policy.DataSourceFederationPolicy, @@ -135,6 +147,9 @@ var autoGeneratedDataSources = []func() datasource.DataSource{ materialized_features_feature_tag.DataSourceFeatureTags, online_store.DataSourceOnlineStores, policy_info.DataSourcePolicyInfos, + postgres_branch.DataSourceBranches, + postgres_endpoint.DataSourceEndpoints, + postgres_project.DataSourceProjects, quality_monitor_v2.DataSourceQualityMonitors, service_principal_federation_policy.DataSourceFederationPolicies, tag_policy.DataSourceTagPolicies, diff --git a/internal/providers/pluginfw/products/online_store/data_online_store.go b/internal/providers/pluginfw/products/online_store/data_online_store.go index c9ad6a97cb..35b0beeb1f 100755 --- a/internal/providers/pluginfw/products/online_store/data_online_store.go +++ b/internal/providers/pluginfw/products/online_store/data_online_store.go @@ -47,6 +47,8 @@ type OnlineStoreData struct { ReadReplicaCount types.Int64 `tfsdk:"read_replica_count"` // The current state of the online store. State types.String `tfsdk:"state"` + // The usage policy applied to the online store to track billing. + UsagePolicyId types.String `tfsdk:"usage_policy_id"` } // GetComplexFieldTypes returns a map of the types of elements in complex fields in the extended @@ -76,6 +78,7 @@ func (m OnlineStoreData) ToObjectValue(ctx context.Context) basetypes.ObjectValu "name": m.Name, "read_replica_count": m.ReadReplicaCount, "state": m.State, + "usage_policy_id": m.UsagePolicyId, }, ) } @@ -91,6 +94,7 @@ func (m OnlineStoreData) Type(ctx context.Context) attr.Type { "name": types.StringType, "read_replica_count": types.Int64Type, "state": types.StringType, + "usage_policy_id": types.StringType, }, } } @@ -102,6 +106,7 @@ func (m OnlineStoreData) ApplySchemaCustomizations(attrs map[string]tfschema.Att attrs["name"] = attrs["name"].SetRequired() attrs["read_replica_count"] = attrs["read_replica_count"].SetComputed() attrs["state"] = attrs["state"].SetComputed() + attrs["usage_policy_id"] = attrs["usage_policy_id"].SetComputed() return attrs } diff --git a/internal/providers/pluginfw/products/online_store/resource_online_store.go b/internal/providers/pluginfw/products/online_store/resource_online_store.go index 4960f94d64..225fc36338 100755 --- a/internal/providers/pluginfw/products/online_store/resource_online_store.go +++ b/internal/providers/pluginfw/products/online_store/resource_online_store.go @@ -53,6 +53,8 @@ type OnlineStore struct { ReadReplicaCount types.Int64 `tfsdk:"read_replica_count"` // The current state of the online store. State types.String `tfsdk:"state"` + // The usage policy applied to the online store to track billing. + UsagePolicyId types.String `tfsdk:"usage_policy_id"` } // GetComplexFieldTypes returns a map of the types of elements in complex fields in the extended @@ -81,6 +83,7 @@ func (m OnlineStore) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "name": m.Name, "read_replica_count": m.ReadReplicaCount, "state": m.State, + "usage_policy_id": m.UsagePolicyId, }, ) } @@ -95,6 +98,7 @@ func (m OnlineStore) Type(ctx context.Context) attr.Type { "name": types.StringType, "read_replica_count": types.Int64Type, "state": types.StringType, + "usage_policy_id": types.StringType, }, } } @@ -118,6 +122,7 @@ func (m OnlineStore) ApplySchemaCustomizations(attrs map[string]tfschema.Attribu attrs["name"] = attrs["name"].SetRequired() attrs["read_replica_count"] = attrs["read_replica_count"].SetOptional() attrs["state"] = attrs["state"].SetComputed() + attrs["usage_policy_id"] = attrs["usage_policy_id"].SetOptional() attrs["name"] = attrs["name"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) return attrs @@ -242,7 +247,7 @@ func (r *OnlineStoreResource) update(ctx context.Context, plan OnlineStore, diag updateRequest := ml.UpdateOnlineStoreRequest{ OnlineStore: online_store, Name: plan.Name.ValueString(), - UpdateMask: "capacity,read_replica_count", + UpdateMask: "capacity,read_replica_count,usage_policy_id", } client, clientDiags := r.Client.GetWorkspaceClient() diff --git a/internal/providers/pluginfw/products/postgres_branch/data_postgres_branch.go b/internal/providers/pluginfw/products/postgres_branch/data_postgres_branch.go new file mode 100755 index 0000000000..0a8cd45a7d --- /dev/null +++ b/internal/providers/pluginfw/products/postgres_branch/data_postgres_branch.go @@ -0,0 +1,240 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package postgres_branch + +import ( + "context" + "reflect" + + "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/autogen" + pluginfwcontext "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/context" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/converters" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +const dataSourceName = "postgres_branch" + +var _ datasource.DataSourceWithConfigure = &BranchDataSource{} + +func DataSourceBranch() datasource.DataSource { + return &BranchDataSource{} +} + +type BranchDataSource struct { + Client *autogen.DatabricksClient +} + +// BranchData extends the main model with additional fields. +type BranchData struct { + // A timestamp indicating when the branch was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + // The branch's state, indicating if it is initializing, ready for use, or + // archived. + CurrentState types.String `tfsdk:"current_state"` + // Whether the branch is the project's default branch. This field is only + // returned on create/update responses. See effective_default for the value + // that is actually applied to the branch. + Default types.Bool `tfsdk:"default"` + // Whether the branch is the project's default branch. + EffectiveDefault types.Bool `tfsdk:"effective_default"` + // Whether the branch is protected. + EffectiveIsProtected types.Bool `tfsdk:"effective_is_protected"` + // The name of the source branch from which this branch was created. Format: + // projects/{project_id}/branches/{branch_id} + EffectiveSourceBranch types.String `tfsdk:"effective_source_branch"` + // The Log Sequence Number (LSN) on the source branch from which this branch + // was created. + EffectiveSourceBranchLsn types.String `tfsdk:"effective_source_branch_lsn"` + // The point in time on the source branch from which this branch was + // created. + EffectiveSourceBranchTime timetypes.RFC3339 `tfsdk:"effective_source_branch_time"` + // Whether the branch is protected. + IsProtected types.Bool `tfsdk:"is_protected"` + // The logical size of the branch. + LogicalSizeBytes types.Int64 `tfsdk:"logical_size_bytes"` + // The resource name of the branch. Format: + // projects/{project_id}/branches/{branch_id} + Name types.String `tfsdk:"name"` + // The project containing this branch. Format: projects/{project_id} + Parent types.String `tfsdk:"parent"` + // The pending state of the branch, if a state transition is in progress. + PendingState types.String `tfsdk:"pending_state"` + // The name of the source branch from which this branch was created. Format: + // projects/{project_id}/branches/{branch_id} + SourceBranch types.String `tfsdk:"source_branch"` + // The Log Sequence Number (LSN) on the source branch from which this branch + // was created. + SourceBranchLsn types.String `tfsdk:"source_branch_lsn"` + // The point in time on the source branch from which this branch was + // created. + SourceBranchTime timetypes.RFC3339 `tfsdk:"source_branch_time"` + // A timestamp indicating when the `current_state` began. + StateChangeTime timetypes.RFC3339 `tfsdk:"state_change_time"` + // System generated unique ID for the branch. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the branch was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in the extended +// BranchData struct. 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 (m BranchData) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{} +} + +// ToObjectValue returns the object value for the resource, combining attributes from the +// embedded TFSDK model and contains additional fields. +// +// 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, BranchData +// only implements ToObjectValue() and Type(). +func (m BranchData) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "create_time": m.CreateTime, + "current_state": m.CurrentState, + "default": m.Default, + "effective_default": m.EffectiveDefault, + "effective_is_protected": m.EffectiveIsProtected, + "effective_source_branch": m.EffectiveSourceBranch, + "effective_source_branch_lsn": m.EffectiveSourceBranchLsn, + "effective_source_branch_time": m.EffectiveSourceBranchTime, + "is_protected": m.IsProtected, + "logical_size_bytes": m.LogicalSizeBytes, + "name": m.Name, + "parent": m.Parent, + "pending_state": m.PendingState, + "source_branch": m.SourceBranch, + "source_branch_lsn": m.SourceBranchLsn, + "source_branch_time": m.SourceBranchTime, + "state_change_time": m.StateChangeTime, + "uid": m.Uid, + "update_time": m.UpdateTime, + }, + ) +} + +// Type returns the object type with attributes from both the embedded TFSDK model +// and contains additional fields. +func (m BranchData) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "create_time": timetypes.RFC3339{}.Type(ctx), + "current_state": types.StringType, + "default": types.BoolType, + "effective_default": types.BoolType, + "effective_is_protected": types.BoolType, + "effective_source_branch": types.StringType, + "effective_source_branch_lsn": types.StringType, + "effective_source_branch_time": timetypes.RFC3339{}.Type(ctx), + "is_protected": types.BoolType, + "logical_size_bytes": types.Int64Type, + "name": types.StringType, + "parent": types.StringType, + "pending_state": types.StringType, + "source_branch": types.StringType, + "source_branch_lsn": types.StringType, + "source_branch_time": timetypes.RFC3339{}.Type(ctx), + "state_change_time": timetypes.RFC3339{}.Type(ctx), + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +func (m BranchData) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["current_state"] = attrs["current_state"].SetComputed() + attrs["default"] = attrs["default"].SetComputed() + attrs["effective_default"] = attrs["effective_default"].SetComputed() + attrs["effective_is_protected"] = attrs["effective_is_protected"].SetComputed() + attrs["effective_source_branch"] = attrs["effective_source_branch"].SetComputed() + attrs["effective_source_branch_lsn"] = attrs["effective_source_branch_lsn"].SetComputed() + attrs["effective_source_branch_time"] = attrs["effective_source_branch_time"].SetComputed() + attrs["is_protected"] = attrs["is_protected"].SetComputed() + attrs["logical_size_bytes"] = attrs["logical_size_bytes"].SetComputed() + attrs["name"] = attrs["name"].SetRequired() + attrs["parent"] = attrs["parent"].SetComputed() + attrs["pending_state"] = attrs["pending_state"].SetComputed() + attrs["source_branch"] = attrs["source_branch"].SetComputed() + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].SetComputed() + attrs["source_branch_time"] = attrs["source_branch_time"].SetComputed() + attrs["state_change_time"] = attrs["state_change_time"].SetComputed() + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + + return attrs +} + +func (r *BranchDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = autogen.GetDatabricksProductionName(dataSourceName) +} + +func (r *BranchDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + attrs, blocks := tfschema.DataSourceStructToSchemaMap(ctx, BranchData{}, nil) + resp.Schema = schema.Schema{ + Description: "Terraform schema for Databricks Branch", + Attributes: attrs, + Blocks: blocks, + } +} + +func (r *BranchDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + r.Client = autogen.ConfigureDataSource(req, resp) +} + +func (r *BranchDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + ctx = pluginfwcontext.SetUserAgentInDataSourceContext(ctx, dataSourceName) + + var config BranchData + resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) + if resp.Diagnostics.HasError() { + return + } + + var readRequest postgres.GetBranchRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, config, &readRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + response, err := client.Postgres.GetBranch(ctx, readRequest) + if err != nil { + if apierr.IsMissing(err) { + resp.State.RemoveResource(ctx) + return + } + + resp.Diagnostics.AddError("failed to get postgres_branch", err.Error()) + return + } + + var newState BranchData + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, response, &newState)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, newState)...) +} diff --git a/internal/providers/pluginfw/products/postgres_branch/data_postgres_branches.go b/internal/providers/pluginfw/products/postgres_branch/data_postgres_branches.go new file mode 100755 index 0000000000..3268396f81 --- /dev/null +++ b/internal/providers/pluginfw/products/postgres_branch/data_postgres_branches.go @@ -0,0 +1,113 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package postgres_branch + +import ( + "context" + "reflect" + + "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/autogen" + pluginfwcontext "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/context" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/converters" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +const dataSourcesName = "postgres_branches" + +var _ datasource.DataSourceWithConfigure = &BranchesDataSource{} + +func DataSourceBranches() datasource.DataSource { + return &BranchesDataSource{} +} + +// BranchesData extends the main model with additional fields. +type BranchesData struct { + Postgres types.List `tfsdk:"branches"` + // Upper bound for items returned. + PageSize types.Int64 `tfsdk:"page_size"` + // The Project that owns this collection of branches. Format: + // projects/{project_id} + Parent types.String `tfsdk:"parent"` +} + +func (BranchesData) GetComplexFieldTypes(context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "branches": reflect.TypeOf(BranchData{}), + } +} + +func (m BranchesData) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["parent"] = attrs["parent"].SetRequired() + attrs["page_size"] = attrs["page_size"].SetOptional() + + attrs["branches"] = attrs["branches"].SetComputed() + return attrs +} + +type BranchesDataSource struct { + Client *autogen.DatabricksClient +} + +func (r *BranchesDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = autogen.GetDatabricksProductionName(dataSourcesName) +} + +func (r *BranchesDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + attrs, blocks := tfschema.DataSourceStructToSchemaMap(ctx, BranchesData{}, nil) + resp.Schema = schema.Schema{ + Description: "Terraform schema for Databricks Branch", + Attributes: attrs, + Blocks: blocks, + } +} + +func (r *BranchesDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + r.Client = autogen.ConfigureDataSource(req, resp) +} + +func (r *BranchesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + ctx = pluginfwcontext.SetUserAgentInDataSourceContext(ctx, dataSourcesName) + + var config BranchesData + resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) + if resp.Diagnostics.HasError() { + return + } + + var listRequest postgres.ListBranchesRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, config, &listRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + response, err := client.Postgres.ListBranchesAll(ctx, listRequest) + if err != nil { + resp.Diagnostics.AddError("failed to list postgres_branches", err.Error()) + return + } + + var results = []attr.Value{} + for _, item := range response { + var branch BranchData + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, item, &branch)...) + if resp.Diagnostics.HasError() { + return + } + results = append(results, branch.ToObjectValue(ctx)) + } + + config.Postgres = types.ListValueMust(BranchData{}.Type(ctx), results) + resp.Diagnostics.Append(resp.State.Set(ctx, config)...) +} diff --git a/internal/providers/pluginfw/products/postgres_branch/resource_postgres_branch.go b/internal/providers/pluginfw/products/postgres_branch/resource_postgres_branch.go new file mode 100755 index 0000000000..4a0f8640d7 --- /dev/null +++ b/internal/providers/pluginfw/products/postgres_branch/resource_postgres_branch.go @@ -0,0 +1,489 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package postgres_branch + +import ( + "context" + "fmt" + "reflect" + "strings" + + "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/databricks-sdk-go/common/types/fieldmask" + "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/autogen" + pluginfwcontext "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/context" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/converters" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +const resourceName = "postgres_branch" + +var _ resource.ResourceWithConfigure = &BranchResource{} + +func ResourceBranch() resource.Resource { + return &BranchResource{} +} + +type BranchResource struct { + Client *autogen.DatabricksClient +} + +// Branch extends the main model with additional fields. +type Branch struct { + // The ID to use for the Branch, which will become the final component of + // the branch's resource name. + // + // This value should be 4-63 characters, and valid characters are + // /[a-z][0-9]-/. + BranchId types.String `tfsdk:"branch_id"` + // A timestamp indicating when the branch was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + // The branch's state, indicating if it is initializing, ready for use, or + // archived. + CurrentState types.String `tfsdk:"current_state"` + // Whether the branch is the project's default branch. This field is only + // returned on create/update responses. See effective_default for the value + // that is actually applied to the branch. + Default types.Bool `tfsdk:"default"` + // Whether the branch is the project's default branch. + EffectiveDefault types.Bool `tfsdk:"effective_default"` + // Whether the branch is protected. + EffectiveIsProtected types.Bool `tfsdk:"effective_is_protected"` + // The name of the source branch from which this branch was created. Format: + // projects/{project_id}/branches/{branch_id} + EffectiveSourceBranch types.String `tfsdk:"effective_source_branch"` + // The Log Sequence Number (LSN) on the source branch from which this branch + // was created. + EffectiveSourceBranchLsn types.String `tfsdk:"effective_source_branch_lsn"` + // The point in time on the source branch from which this branch was + // created. + EffectiveSourceBranchTime timetypes.RFC3339 `tfsdk:"effective_source_branch_time"` + // Whether the branch is protected. + IsProtected types.Bool `tfsdk:"is_protected"` + // The logical size of the branch. + LogicalSizeBytes types.Int64 `tfsdk:"logical_size_bytes"` + // The resource name of the branch. Format: + // projects/{project_id}/branches/{branch_id} + Name types.String `tfsdk:"name"` + // The project containing this branch. Format: projects/{project_id} + Parent types.String `tfsdk:"parent"` + // The pending state of the branch, if a state transition is in progress. + PendingState types.String `tfsdk:"pending_state"` + // The name of the source branch from which this branch was created. Format: + // projects/{project_id}/branches/{branch_id} + SourceBranch types.String `tfsdk:"source_branch"` + // The Log Sequence Number (LSN) on the source branch from which this branch + // was created. + SourceBranchLsn types.String `tfsdk:"source_branch_lsn"` + // The point in time on the source branch from which this branch was + // created. + SourceBranchTime timetypes.RFC3339 `tfsdk:"source_branch_time"` + // A timestamp indicating when the `current_state` began. + StateChangeTime timetypes.RFC3339 `tfsdk:"state_change_time"` + // System generated unique ID for the branch. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the branch was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in the extended +// Branch struct. 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 (m Branch) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{} +} + +// ToObjectValue returns the object value for the resource, combining attributes from the +// embedded TFSDK model and contains additional fields. +// +// 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, Branch +// only implements ToObjectValue() and Type(). +func (m Branch) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{"branch_id": m.BranchId, + "create_time": m.CreateTime, + "current_state": m.CurrentState, + "default": m.Default, + "effective_default": m.EffectiveDefault, + "effective_is_protected": m.EffectiveIsProtected, + "effective_source_branch": m.EffectiveSourceBranch, + "effective_source_branch_lsn": m.EffectiveSourceBranchLsn, + "effective_source_branch_time": m.EffectiveSourceBranchTime, + "is_protected": m.IsProtected, + "logical_size_bytes": m.LogicalSizeBytes, + "name": m.Name, + "parent": m.Parent, + "pending_state": m.PendingState, + "source_branch": m.SourceBranch, + "source_branch_lsn": m.SourceBranchLsn, + "source_branch_time": m.SourceBranchTime, + "state_change_time": m.StateChangeTime, + "uid": m.Uid, + "update_time": m.UpdateTime, + }, + ) +} + +// Type returns the object type with attributes from both the embedded TFSDK model +// and contains additional fields. +func (m Branch) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{"branch_id": types.StringType, + "create_time": timetypes.RFC3339{}.Type(ctx), + "current_state": types.StringType, + "default": types.BoolType, + "effective_default": types.BoolType, + "effective_is_protected": types.BoolType, + "effective_source_branch": types.StringType, + "effective_source_branch_lsn": types.StringType, + "effective_source_branch_time": timetypes.RFC3339{}.Type(ctx), + "is_protected": types.BoolType, + "logical_size_bytes": types.Int64Type, + "name": types.StringType, + "parent": types.StringType, + "pending_state": types.StringType, + "source_branch": types.StringType, + "source_branch_lsn": types.StringType, + "source_branch_time": timetypes.RFC3339{}.Type(ctx), + "state_change_time": timetypes.RFC3339{}.Type(ctx), + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +// SyncFieldsDuringCreateOrUpdate copies values from the plan into the receiver, +// including both embedded model fields and additional fields. This method is called +// during create and update. +func (to *Branch) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Branch) { + to.BranchId = from.BranchId + if !from.Default.IsUnknown() && !from.Default.IsNull() { + // Default is an input only field and not returned by the service, so we keep the value from the prior state. + to.Default = from.Default + } + if !from.IsProtected.IsUnknown() && !from.IsProtected.IsNull() { + // IsProtected is an input only field and not returned by the service, so we keep the value from the prior state. + to.IsProtected = from.IsProtected + } + if !from.SourceBranch.IsUnknown() && !from.SourceBranch.IsNull() { + // SourceBranch is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranch = from.SourceBranch + } + if !from.SourceBranchLsn.IsUnknown() && !from.SourceBranchLsn.IsNull() { + // SourceBranchLsn is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchLsn = from.SourceBranchLsn + } + if !from.SourceBranchTime.IsUnknown() && !from.SourceBranchTime.IsNull() { + // SourceBranchTime is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchTime = from.SourceBranchTime + } +} + +// SyncFieldsDuringRead copies values from the existing state into the receiver, +// including both embedded model fields and additional fields. This method is called +// during read. +func (to *Branch) SyncFieldsDuringRead(ctx context.Context, from Branch) { + to.BranchId = from.BranchId + if !from.Default.IsUnknown() && !from.Default.IsNull() { + // Default is an input only field and not returned by the service, so we keep the value from the prior state. + to.Default = from.Default + } + if !from.IsProtected.IsUnknown() && !from.IsProtected.IsNull() { + // IsProtected is an input only field and not returned by the service, so we keep the value from the prior state. + to.IsProtected = from.IsProtected + } + if !from.SourceBranch.IsUnknown() && !from.SourceBranch.IsNull() { + // SourceBranch is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranch = from.SourceBranch + } + if !from.SourceBranchLsn.IsUnknown() && !from.SourceBranchLsn.IsNull() { + // SourceBranchLsn is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchLsn = from.SourceBranchLsn + } + if !from.SourceBranchTime.IsUnknown() && !from.SourceBranchTime.IsNull() { + // SourceBranchTime is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchTime = from.SourceBranchTime + } +} + +func (m Branch) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["current_state"] = attrs["current_state"].SetComputed() + attrs["default"] = attrs["default"].SetOptional() + attrs["default"] = attrs["default"].SetComputed() + attrs["default"] = attrs["default"].(tfschema.BoolAttributeBuilder).AddPlanModifier(boolplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["effective_default"] = attrs["effective_default"].SetComputed() + attrs["effective_is_protected"] = attrs["effective_is_protected"].SetComputed() + attrs["effective_source_branch"] = attrs["effective_source_branch"].SetComputed() + attrs["effective_source_branch_lsn"] = attrs["effective_source_branch_lsn"].SetComputed() + attrs["effective_source_branch_time"] = attrs["effective_source_branch_time"].SetComputed() + attrs["is_protected"] = attrs["is_protected"].SetOptional() + attrs["is_protected"] = attrs["is_protected"].SetComputed() + attrs["is_protected"] = attrs["is_protected"].(tfschema.BoolAttributeBuilder).AddPlanModifier(boolplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["logical_size_bytes"] = attrs["logical_size_bytes"].SetComputed() + attrs["name"] = attrs["name"].SetComputed() + attrs["parent"] = attrs["parent"].SetRequired() + attrs["parent"] = attrs["parent"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["pending_state"] = attrs["pending_state"].SetComputed() + attrs["source_branch"] = attrs["source_branch"].SetOptional() + attrs["source_branch"] = attrs["source_branch"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["source_branch"] = attrs["source_branch"].SetComputed() + attrs["source_branch"] = attrs["source_branch"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].SetOptional() + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].SetComputed() + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["source_branch_time"] = attrs["source_branch_time"].SetOptional() + attrs["source_branch_time"] = attrs["source_branch_time"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["source_branch_time"] = attrs["source_branch_time"].SetComputed() + attrs["source_branch_time"] = attrs["source_branch_time"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["state_change_time"] = attrs["state_change_time"].SetComputed() + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + attrs["branch_id"] = attrs["branch_id"].SetComputed() + attrs["branch_id"] = attrs["branch_id"].SetOptional() + attrs["branch_id"] = attrs["branch_id"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + + attrs["name"] = attrs["name"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + return attrs +} + +func (r *BranchResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = autogen.GetDatabricksProductionName(resourceName) +} + +func (r *BranchResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + attrs, blocks := tfschema.ResourceStructToSchemaMap(ctx, Branch{}, nil) + resp.Schema = schema.Schema{ + Description: "Terraform schema for Databricks postgres_branch", + Attributes: attrs, + Blocks: blocks, + } +} + +func (r *BranchResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + r.Client = autogen.ConfigureResource(req, resp) +} + +func (r *BranchResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var plan Branch + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + var branch postgres.Branch + + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, plan, &branch)...) + if resp.Diagnostics.HasError() { + return + } + + createRequest := postgres.CreateBranchRequest{ + Branch: branch, + Parent: plan.Parent.ValueString(), + BranchId: plan.BranchId.ValueString(), + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + response, err := client.Postgres.CreateBranch(ctx, createRequest) + if err != nil { + resp.Diagnostics.AddError("failed to create postgres_branch", err.Error()) + return + } + + var newState Branch + + waitResponse, err := response.Wait(ctx) + if err != nil { + resp.Diagnostics.AddError("error waiting for postgres_branch to be ready", err.Error()) + return + } + + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, waitResponse, &newState)...) + + if resp.Diagnostics.HasError() { + return + } + + newState.SyncFieldsDuringCreateOrUpdate(ctx, plan) + + resp.Diagnostics.Append(resp.State.Set(ctx, newState)...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *BranchResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var existingState Branch + resp.Diagnostics.Append(req.State.Get(ctx, &existingState)...) + if resp.Diagnostics.HasError() { + return + } + + var readRequest postgres.GetBranchRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, existingState, &readRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + response, err := client.Postgres.GetBranch(ctx, readRequest) + if err != nil { + if apierr.IsMissing(err) { + resp.State.RemoveResource(ctx) + return + } + + resp.Diagnostics.AddError("failed to get postgres_branch", err.Error()) + return + } + + var newState Branch + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, response, &newState)...) + if resp.Diagnostics.HasError() { + return + } + + newState.SyncFieldsDuringRead(ctx, existingState) + + resp.Diagnostics.Append(resp.State.Set(ctx, newState)...) +} + +func (r *BranchResource) update(ctx context.Context, plan Branch, diags *diag.Diagnostics, state *tfsdk.State) { + var branch postgres.Branch + + diags.Append(converters.TfSdkToGoSdkStruct(ctx, plan, &branch)...) + if diags.HasError() { + return + } + + updateRequest := postgres.UpdateBranchRequest{ + Branch: branch, + Name: plan.Name.ValueString(), + UpdateMask: *fieldmask.New(strings.Split("default,is_protected", ",")), + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + diags.Append(clientDiags...) + if diags.HasError() { + return + } + response, err := client.Postgres.UpdateBranch(ctx, updateRequest) + if err != nil { + diags.AddError("failed to update postgres_branch", err.Error()) + return + } + + var newState Branch + + waitResponse, err := response.Wait(ctx) + if err != nil { + diags.AddError("error waiting for postgres_branch update", err.Error()) + return + } + + diags.Append(converters.GoSdkToTfSdkStruct(ctx, waitResponse, &newState)...) + + if diags.HasError() { + return + } + + newState.SyncFieldsDuringCreateOrUpdate(ctx, plan) + diags.Append(state.Set(ctx, newState)...) +} + +func (r *BranchResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var plan Branch + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + r.update(ctx, plan, &resp.Diagnostics, &resp.State) +} + +func (r *BranchResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var state Branch + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + var deleteRequest postgres.DeleteBranchRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, state, &deleteRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + err := client.Postgres.DeleteBranch(ctx, deleteRequest) + if err != nil && !apierr.IsMissing(err) { + resp.Diagnostics.AddError("failed to delete postgres_branch", err.Error()) + return + } + +} + +var _ resource.ResourceWithImportState = &BranchResource{} + +func (r *BranchResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + parts := strings.Split(req.ID, ",") + + if len(parts) != 1 || parts[0] == "" { + resp.Diagnostics.AddError( + "Unexpected Import Identifier", + fmt.Sprintf( + "Expected import identifier with format: name. Got: %q", + req.ID, + ), + ) + return + } + + name := parts[0] + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), name)...) +} diff --git a/internal/providers/pluginfw/products/postgres_endpoint/data_postgres_endpoint.go b/internal/providers/pluginfw/products/postgres_endpoint/data_postgres_endpoint.go new file mode 100755 index 0000000000..c3931adf26 --- /dev/null +++ b/internal/providers/pluginfw/products/postgres_endpoint/data_postgres_endpoint.go @@ -0,0 +1,269 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package postgres_endpoint + +import ( + "context" + "reflect" + + "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/autogen" + pluginfwcontext "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/context" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/converters" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + "github.com/databricks/terraform-provider-databricks/internal/service/postgres_tf" + "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +const dataSourceName = "postgres_endpoint" + +var _ datasource.DataSourceWithConfigure = &EndpointDataSource{} + +func DataSourceEndpoint() datasource.DataSource { + return &EndpointDataSource{} +} + +type EndpointDataSource struct { + Client *autogen.DatabricksClient +} + +// EndpointData extends the main model with additional fields. +type EndpointData struct { + // The maximum number of Compute Units. + AutoscalingLimitMaxCu types.Float64 `tfsdk:"autoscaling_limit_max_cu"` + // The minimum number of Compute Units. + AutoscalingLimitMinCu types.Float64 `tfsdk:"autoscaling_limit_min_cu"` + // A timestamp indicating when the compute endpoint was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + + CurrentState types.String `tfsdk:"current_state"` + // Whether to restrict connections to the compute endpoint. Enabling this + // option schedules a suspend compute operation. A disabled compute endpoint + // cannot be enabled by a connection or console action. + Disabled types.Bool `tfsdk:"disabled"` + // The maximum number of Compute Units. + EffectiveAutoscalingLimitMaxCu types.Float64 `tfsdk:"effective_autoscaling_limit_max_cu"` + // The minimum number of Compute Units. + EffectiveAutoscalingLimitMinCu types.Float64 `tfsdk:"effective_autoscaling_limit_min_cu"` + // Whether to restrict connections to the compute endpoint. Enabling this + // option schedules a suspend compute operation. A disabled compute endpoint + // cannot be enabled by a connection or console action. + EffectiveDisabled types.Bool `tfsdk:"effective_disabled"` + + EffectivePoolerMode types.String `tfsdk:"effective_pooler_mode"` + + EffectiveSettings types.Object `tfsdk:"effective_settings"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + EffectiveSuspendTimeoutDuration timetypes.GoDuration `tfsdk:"effective_suspend_timeout_duration"` + // The endpoint type. There could be only one READ_WRITE endpoint per + // branch. + EndpointType types.String `tfsdk:"endpoint_type"` + // The hostname of the compute endpoint. This is the hostname specified when + // connecting to a database. + Host types.String `tfsdk:"host"` + // A timestamp indicating when the compute endpoint was last active. + LastActiveTime timetypes.RFC3339 `tfsdk:"last_active_time"` + // The resource name of the endpoint. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name types.String `tfsdk:"name"` + // The branch containing this endpoint. Format: + // projects/{project_id}/branches/{branch_id} + Parent types.String `tfsdk:"parent"` + + PendingState types.String `tfsdk:"pending_state"` + + PoolerMode types.String `tfsdk:"pooler_mode"` + + Settings types.Object `tfsdk:"settings"` + // A timestamp indicating when the compute endpoint was last started. + StartTime timetypes.RFC3339 `tfsdk:"start_time"` + // A timestamp indicating when the compute endpoint was last suspended. + SuspendTime timetypes.RFC3339 `tfsdk:"suspend_time"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + SuspendTimeoutDuration timetypes.GoDuration `tfsdk:"suspend_timeout_duration"` + // System generated unique ID for the endpoint. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the compute endpoint was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in the extended +// EndpointData struct. 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 (m EndpointData) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "effective_settings": reflect.TypeOf(postgres_tf.EndpointSettings{}), + "settings": reflect.TypeOf(postgres_tf.EndpointSettings{}), + } +} + +// ToObjectValue returns the object value for the resource, combining attributes from the +// embedded TFSDK model and contains additional fields. +// +// 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, EndpointData +// only implements ToObjectValue() and Type(). +func (m EndpointData) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "autoscaling_limit_max_cu": m.AutoscalingLimitMaxCu, + "autoscaling_limit_min_cu": m.AutoscalingLimitMinCu, + "create_time": m.CreateTime, + "current_state": m.CurrentState, + "disabled": m.Disabled, + "effective_autoscaling_limit_max_cu": m.EffectiveAutoscalingLimitMaxCu, + "effective_autoscaling_limit_min_cu": m.EffectiveAutoscalingLimitMinCu, + "effective_disabled": m.EffectiveDisabled, + "effective_pooler_mode": m.EffectivePoolerMode, + "effective_settings": m.EffectiveSettings, + "effective_suspend_timeout_duration": m.EffectiveSuspendTimeoutDuration, + "endpoint_type": m.EndpointType, + "host": m.Host, + "last_active_time": m.LastActiveTime, + "name": m.Name, + "parent": m.Parent, + "pending_state": m.PendingState, + "pooler_mode": m.PoolerMode, + "settings": m.Settings, + "start_time": m.StartTime, + "suspend_time": m.SuspendTime, + "suspend_timeout_duration": m.SuspendTimeoutDuration, + "uid": m.Uid, + "update_time": m.UpdateTime, + }, + ) +} + +// Type returns the object type with attributes from both the embedded TFSDK model +// and contains additional fields. +func (m EndpointData) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "autoscaling_limit_max_cu": types.Float64Type, + "autoscaling_limit_min_cu": types.Float64Type, + "create_time": timetypes.RFC3339{}.Type(ctx), + "current_state": types.StringType, + "disabled": types.BoolType, + "effective_autoscaling_limit_max_cu": types.Float64Type, + "effective_autoscaling_limit_min_cu": types.Float64Type, + "effective_disabled": types.BoolType, + "effective_pooler_mode": types.StringType, + "effective_settings": postgres_tf.EndpointSettings{}.Type(ctx), + "effective_suspend_timeout_duration": timetypes.GoDuration{}.Type(ctx), + "endpoint_type": types.StringType, + "host": types.StringType, + "last_active_time": timetypes.RFC3339{}.Type(ctx), + "name": types.StringType, + "parent": types.StringType, + "pending_state": types.StringType, + "pooler_mode": types.StringType, + "settings": postgres_tf.EndpointSettings{}.Type(ctx), + "start_time": timetypes.RFC3339{}.Type(ctx), + "suspend_time": timetypes.RFC3339{}.Type(ctx), + "suspend_timeout_duration": timetypes.GoDuration{}.Type(ctx), + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +func (m EndpointData) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].SetComputed() + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].SetComputed() + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["current_state"] = attrs["current_state"].SetComputed() + attrs["disabled"] = attrs["disabled"].SetComputed() + attrs["effective_autoscaling_limit_max_cu"] = attrs["effective_autoscaling_limit_max_cu"].SetComputed() + attrs["effective_autoscaling_limit_min_cu"] = attrs["effective_autoscaling_limit_min_cu"].SetComputed() + attrs["effective_disabled"] = attrs["effective_disabled"].SetComputed() + attrs["effective_pooler_mode"] = attrs["effective_pooler_mode"].SetComputed() + attrs["effective_settings"] = attrs["effective_settings"].SetComputed() + attrs["effective_suspend_timeout_duration"] = attrs["effective_suspend_timeout_duration"].SetComputed() + attrs["endpoint_type"] = attrs["endpoint_type"].SetComputed() + attrs["host"] = attrs["host"].SetComputed() + attrs["last_active_time"] = attrs["last_active_time"].SetComputed() + attrs["name"] = attrs["name"].SetRequired() + attrs["parent"] = attrs["parent"].SetComputed() + attrs["pending_state"] = attrs["pending_state"].SetComputed() + attrs["pooler_mode"] = attrs["pooler_mode"].SetComputed() + attrs["settings"] = attrs["settings"].SetComputed() + attrs["start_time"] = attrs["start_time"].SetComputed() + attrs["suspend_time"] = attrs["suspend_time"].SetComputed() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].SetComputed() + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + + return attrs +} + +func (r *EndpointDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = autogen.GetDatabricksProductionName(dataSourceName) +} + +func (r *EndpointDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + attrs, blocks := tfschema.DataSourceStructToSchemaMap(ctx, EndpointData{}, nil) + resp.Schema = schema.Schema{ + Description: "Terraform schema for Databricks Endpoint", + Attributes: attrs, + Blocks: blocks, + } +} + +func (r *EndpointDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + r.Client = autogen.ConfigureDataSource(req, resp) +} + +func (r *EndpointDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + ctx = pluginfwcontext.SetUserAgentInDataSourceContext(ctx, dataSourceName) + + var config EndpointData + resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) + if resp.Diagnostics.HasError() { + return + } + + var readRequest postgres.GetEndpointRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, config, &readRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + response, err := client.Postgres.GetEndpoint(ctx, readRequest) + if err != nil { + if apierr.IsMissing(err) { + resp.State.RemoveResource(ctx) + return + } + + resp.Diagnostics.AddError("failed to get postgres_endpoint", err.Error()) + return + } + + var newState EndpointData + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, response, &newState)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, newState)...) +} diff --git a/internal/providers/pluginfw/products/postgres_endpoint/data_postgres_endpoints.go b/internal/providers/pluginfw/products/postgres_endpoint/data_postgres_endpoints.go new file mode 100755 index 0000000000..887e94e9fc --- /dev/null +++ b/internal/providers/pluginfw/products/postgres_endpoint/data_postgres_endpoints.go @@ -0,0 +1,113 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package postgres_endpoint + +import ( + "context" + "reflect" + + "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/autogen" + pluginfwcontext "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/context" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/converters" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +const dataSourcesName = "postgres_endpoints" + +var _ datasource.DataSourceWithConfigure = &EndpointsDataSource{} + +func DataSourceEndpoints() datasource.DataSource { + return &EndpointsDataSource{} +} + +// EndpointsData extends the main model with additional fields. +type EndpointsData struct { + Postgres types.List `tfsdk:"endpoints"` + // Upper bound for items returned. + PageSize types.Int64 `tfsdk:"page_size"` + // The Branch that owns this collection of endpoints. Format: + // projects/{project_id}/branches/{branch_id} + Parent types.String `tfsdk:"parent"` +} + +func (EndpointsData) GetComplexFieldTypes(context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "endpoints": reflect.TypeOf(EndpointData{}), + } +} + +func (m EndpointsData) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["parent"] = attrs["parent"].SetRequired() + attrs["page_size"] = attrs["page_size"].SetOptional() + + attrs["endpoints"] = attrs["endpoints"].SetComputed() + return attrs +} + +type EndpointsDataSource struct { + Client *autogen.DatabricksClient +} + +func (r *EndpointsDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = autogen.GetDatabricksProductionName(dataSourcesName) +} + +func (r *EndpointsDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + attrs, blocks := tfschema.DataSourceStructToSchemaMap(ctx, EndpointsData{}, nil) + resp.Schema = schema.Schema{ + Description: "Terraform schema for Databricks Endpoint", + Attributes: attrs, + Blocks: blocks, + } +} + +func (r *EndpointsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + r.Client = autogen.ConfigureDataSource(req, resp) +} + +func (r *EndpointsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + ctx = pluginfwcontext.SetUserAgentInDataSourceContext(ctx, dataSourcesName) + + var config EndpointsData + resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) + if resp.Diagnostics.HasError() { + return + } + + var listRequest postgres.ListEndpointsRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, config, &listRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + response, err := client.Postgres.ListEndpointsAll(ctx, listRequest) + if err != nil { + resp.Diagnostics.AddError("failed to list postgres_endpoints", err.Error()) + return + } + + var results = []attr.Value{} + for _, item := range response { + var endpoint EndpointData + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, item, &endpoint)...) + if resp.Diagnostics.HasError() { + return + } + results = append(results, endpoint.ToObjectValue(ctx)) + } + + config.Postgres = types.ListValueMust(EndpointData{}.Type(ctx), results) + resp.Diagnostics.Append(resp.State.Set(ctx, config)...) +} diff --git a/internal/providers/pluginfw/products/postgres_endpoint/resource_postgres_endpoint.go b/internal/providers/pluginfw/products/postgres_endpoint/resource_postgres_endpoint.go new file mode 100755 index 0000000000..c16bfd223b --- /dev/null +++ b/internal/providers/pluginfw/products/postgres_endpoint/resource_postgres_endpoint.go @@ -0,0 +1,613 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package postgres_endpoint + +import ( + "context" + "fmt" + "reflect" + "strings" + + "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/databricks-sdk-go/common/types/fieldmask" + "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/autogen" + pluginfwcommon "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/common" + pluginfwcontext "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/context" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/converters" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + "github.com/databricks/terraform-provider-databricks/internal/service/postgres_tf" + "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/float64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +const resourceName = "postgres_endpoint" + +var _ resource.ResourceWithConfigure = &EndpointResource{} + +func ResourceEndpoint() resource.Resource { + return &EndpointResource{} +} + +type EndpointResource struct { + Client *autogen.DatabricksClient +} + +// Endpoint extends the main model with additional fields. +type Endpoint struct { + // The maximum number of Compute Units. + AutoscalingLimitMaxCu types.Float64 `tfsdk:"autoscaling_limit_max_cu"` + // The minimum number of Compute Units. + AutoscalingLimitMinCu types.Float64 `tfsdk:"autoscaling_limit_min_cu"` + // A timestamp indicating when the compute endpoint was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + + CurrentState types.String `tfsdk:"current_state"` + // Whether to restrict connections to the compute endpoint. Enabling this + // option schedules a suspend compute operation. A disabled compute endpoint + // cannot be enabled by a connection or console action. + Disabled types.Bool `tfsdk:"disabled"` + // The maximum number of Compute Units. + EffectiveAutoscalingLimitMaxCu types.Float64 `tfsdk:"effective_autoscaling_limit_max_cu"` + // The minimum number of Compute Units. + EffectiveAutoscalingLimitMinCu types.Float64 `tfsdk:"effective_autoscaling_limit_min_cu"` + // Whether to restrict connections to the compute endpoint. Enabling this + // option schedules a suspend compute operation. A disabled compute endpoint + // cannot be enabled by a connection or console action. + EffectiveDisabled types.Bool `tfsdk:"effective_disabled"` + + EffectivePoolerMode types.String `tfsdk:"effective_pooler_mode"` + + EffectiveSettings types.Object `tfsdk:"effective_settings"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + EffectiveSuspendTimeoutDuration timetypes.GoDuration `tfsdk:"effective_suspend_timeout_duration"` + // The ID to use for the Endpoint, which will become the final component of + // the endpoint's resource name. + // + // This value should be 4-63 characters, and valid characters are + // /[a-z][0-9]-/. + EndpointId types.String `tfsdk:"endpoint_id"` + // The endpoint type. There could be only one READ_WRITE endpoint per + // branch. + EndpointType types.String `tfsdk:"endpoint_type"` + // The hostname of the compute endpoint. This is the hostname specified when + // connecting to a database. + Host types.String `tfsdk:"host"` + // A timestamp indicating when the compute endpoint was last active. + LastActiveTime timetypes.RFC3339 `tfsdk:"last_active_time"` + // The resource name of the endpoint. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name types.String `tfsdk:"name"` + // The branch containing this endpoint. Format: + // projects/{project_id}/branches/{branch_id} + Parent types.String `tfsdk:"parent"` + + PendingState types.String `tfsdk:"pending_state"` + + PoolerMode types.String `tfsdk:"pooler_mode"` + + Settings types.Object `tfsdk:"settings"` + // A timestamp indicating when the compute endpoint was last started. + StartTime timetypes.RFC3339 `tfsdk:"start_time"` + // A timestamp indicating when the compute endpoint was last suspended. + SuspendTime timetypes.RFC3339 `tfsdk:"suspend_time"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + SuspendTimeoutDuration timetypes.GoDuration `tfsdk:"suspend_timeout_duration"` + // System generated unique ID for the endpoint. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the compute endpoint was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in the extended +// Endpoint struct. 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 (m Endpoint) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "effective_settings": reflect.TypeOf(postgres_tf.EndpointSettings{}), + "settings": reflect.TypeOf(postgres_tf.EndpointSettings{}), + } +} + +// ToObjectValue returns the object value for the resource, combining attributes from the +// embedded TFSDK model and contains additional fields. +// +// 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, Endpoint +// only implements ToObjectValue() and Type(). +func (m Endpoint) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{"autoscaling_limit_max_cu": m.AutoscalingLimitMaxCu, + "autoscaling_limit_min_cu": m.AutoscalingLimitMinCu, + "create_time": m.CreateTime, + "current_state": m.CurrentState, + "disabled": m.Disabled, + "effective_autoscaling_limit_max_cu": m.EffectiveAutoscalingLimitMaxCu, + "effective_autoscaling_limit_min_cu": m.EffectiveAutoscalingLimitMinCu, + "effective_disabled": m.EffectiveDisabled, + "effective_pooler_mode": m.EffectivePoolerMode, + "effective_settings": m.EffectiveSettings, + "effective_suspend_timeout_duration": m.EffectiveSuspendTimeoutDuration, + "endpoint_id": m.EndpointId, + "endpoint_type": m.EndpointType, + "host": m.Host, + "last_active_time": m.LastActiveTime, + "name": m.Name, + "parent": m.Parent, + "pending_state": m.PendingState, + "pooler_mode": m.PoolerMode, + "settings": m.Settings, + "start_time": m.StartTime, + "suspend_time": m.SuspendTime, + "suspend_timeout_duration": m.SuspendTimeoutDuration, + "uid": m.Uid, + "update_time": m.UpdateTime, + }, + ) +} + +// Type returns the object type with attributes from both the embedded TFSDK model +// and contains additional fields. +func (m Endpoint) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{"autoscaling_limit_max_cu": types.Float64Type, + "autoscaling_limit_min_cu": types.Float64Type, + "create_time": timetypes.RFC3339{}.Type(ctx), + "current_state": types.StringType, + "disabled": types.BoolType, + "effective_autoscaling_limit_max_cu": types.Float64Type, + "effective_autoscaling_limit_min_cu": types.Float64Type, + "effective_disabled": types.BoolType, + "effective_pooler_mode": types.StringType, + "effective_settings": postgres_tf.EndpointSettings{}.Type(ctx), + "effective_suspend_timeout_duration": timetypes.GoDuration{}.Type(ctx), + "endpoint_id": types.StringType, + "endpoint_type": types.StringType, + "host": types.StringType, + "last_active_time": timetypes.RFC3339{}.Type(ctx), + "name": types.StringType, + "parent": types.StringType, + "pending_state": types.StringType, + "pooler_mode": types.StringType, + "settings": postgres_tf.EndpointSettings{}.Type(ctx), + "start_time": timetypes.RFC3339{}.Type(ctx), + "suspend_time": timetypes.RFC3339{}.Type(ctx), + "suspend_timeout_duration": timetypes.GoDuration{}.Type(ctx), + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +// SyncFieldsDuringCreateOrUpdate copies values from the plan into the receiver, +// including both embedded model fields and additional fields. This method is called +// during create and update. +func (to *Endpoint) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Endpoint) { + if !from.AutoscalingLimitMaxCu.IsUnknown() && !from.AutoscalingLimitMaxCu.IsNull() { + // AutoscalingLimitMaxCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMaxCu = from.AutoscalingLimitMaxCu + } + if !from.AutoscalingLimitMinCu.IsUnknown() && !from.AutoscalingLimitMinCu.IsNull() { + // AutoscalingLimitMinCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMinCu = from.AutoscalingLimitMinCu + } + if !from.Disabled.IsUnknown() && !from.Disabled.IsNull() { + // Disabled is an input only field and not returned by the service, so we keep the value from the prior state. + to.Disabled = from.Disabled + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + // Recursively sync the fields of EffectiveSettings + toEffectiveSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + to.EndpointId = from.EndpointId + if !from.PoolerMode.IsUnknown() && !from.PoolerMode.IsNull() { + // PoolerMode is an input only field and not returned by the service, so we keep the value from the prior state. + to.PoolerMode = from.PoolerMode + } + if !from.Settings.IsUnknown() && !from.Settings.IsNull() { + // Settings is an input only field and not returned by the service, so we keep the value from the prior state. + to.Settings = from.Settings + } + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + // Recursively sync the fields of Settings + toSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } + if !from.SuspendTimeoutDuration.IsUnknown() && !from.SuspendTimeoutDuration.IsNull() { + // SuspendTimeoutDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.SuspendTimeoutDuration = from.SuspendTimeoutDuration + } +} + +// SyncFieldsDuringRead copies values from the existing state into the receiver, +// including both embedded model fields and additional fields. This method is called +// during read. +func (to *Endpoint) SyncFieldsDuringRead(ctx context.Context, from Endpoint) { + if !from.AutoscalingLimitMaxCu.IsUnknown() && !from.AutoscalingLimitMaxCu.IsNull() { + // AutoscalingLimitMaxCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMaxCu = from.AutoscalingLimitMaxCu + } + if !from.AutoscalingLimitMinCu.IsUnknown() && !from.AutoscalingLimitMinCu.IsNull() { + // AutoscalingLimitMinCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMinCu = from.AutoscalingLimitMinCu + } + if !from.Disabled.IsUnknown() && !from.Disabled.IsNull() { + // Disabled is an input only field and not returned by the service, so we keep the value from the prior state. + to.Disabled = from.Disabled + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + toEffectiveSettings.SyncFieldsDuringRead(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + to.EndpointId = from.EndpointId + if !from.PoolerMode.IsUnknown() && !from.PoolerMode.IsNull() { + // PoolerMode is an input only field and not returned by the service, so we keep the value from the prior state. + to.PoolerMode = from.PoolerMode + } + if !from.Settings.IsUnknown() && !from.Settings.IsNull() { + // Settings is an input only field and not returned by the service, so we keep the value from the prior state. + to.Settings = from.Settings + } + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + toSettings.SyncFieldsDuringRead(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } + if !from.SuspendTimeoutDuration.IsUnknown() && !from.SuspendTimeoutDuration.IsNull() { + // SuspendTimeoutDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.SuspendTimeoutDuration = from.SuspendTimeoutDuration + } +} + +func (m Endpoint) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].SetOptional() + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].SetComputed() + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].(tfschema.Float64AttributeBuilder).AddPlanModifier(float64planmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].SetOptional() + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].SetComputed() + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].(tfschema.Float64AttributeBuilder).AddPlanModifier(float64planmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["current_state"] = attrs["current_state"].SetComputed() + attrs["disabled"] = attrs["disabled"].SetOptional() + attrs["disabled"] = attrs["disabled"].SetComputed() + attrs["disabled"] = attrs["disabled"].(tfschema.BoolAttributeBuilder).AddPlanModifier(boolplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["effective_autoscaling_limit_max_cu"] = attrs["effective_autoscaling_limit_max_cu"].SetComputed() + attrs["effective_autoscaling_limit_min_cu"] = attrs["effective_autoscaling_limit_min_cu"].SetComputed() + attrs["effective_disabled"] = attrs["effective_disabled"].SetComputed() + attrs["effective_pooler_mode"] = attrs["effective_pooler_mode"].SetComputed() + attrs["effective_settings"] = attrs["effective_settings"].SetComputed() + attrs["effective_suspend_timeout_duration"] = attrs["effective_suspend_timeout_duration"].SetComputed() + attrs["endpoint_type"] = attrs["endpoint_type"].SetRequired() + attrs["endpoint_type"] = attrs["endpoint_type"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["host"] = attrs["host"].SetComputed() + attrs["last_active_time"] = attrs["last_active_time"].SetComputed() + attrs["name"] = attrs["name"].SetComputed() + attrs["parent"] = attrs["parent"].SetRequired() + attrs["parent"] = attrs["parent"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["pending_state"] = attrs["pending_state"].SetComputed() + attrs["pooler_mode"] = attrs["pooler_mode"].SetOptional() + attrs["pooler_mode"] = attrs["pooler_mode"].SetComputed() + attrs["pooler_mode"] = attrs["pooler_mode"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["settings"] = attrs["settings"].SetOptional() + attrs["settings"] = attrs["settings"].SetComputed() + attrs["settings"] = attrs["settings"].(tfschema.SingleNestedAttributeBuilder).AddPlanModifier(objectplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["start_time"] = attrs["start_time"].SetComputed() + attrs["suspend_time"] = attrs["suspend_time"].SetComputed() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].SetOptional() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].SetComputed() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + attrs["endpoint_id"] = attrs["endpoint_id"].SetComputed() + attrs["endpoint_id"] = attrs["endpoint_id"].SetOptional() + attrs["endpoint_id"] = attrs["endpoint_id"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + + attrs["name"] = attrs["name"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + return attrs +} + +// GetEffectiveSettings returns the value of the EffectiveSettings field in Endpoint as +// a postgres_tf.EndpointSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Endpoint) GetEffectiveSettings(ctx context.Context) (postgres_tf.EndpointSettings, bool) { + var e postgres_tf.EndpointSettings + if m.EffectiveSettings.IsNull() || m.EffectiveSettings.IsUnknown() { + return e, false + } + var v postgres_tf.EndpointSettings + d := m.EffectiveSettings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetEffectiveSettings sets the value of the EffectiveSettings field in Endpoint. +func (m *Endpoint) SetEffectiveSettings(ctx context.Context, v postgres_tf.EndpointSettings) { + vs := v.ToObjectValue(ctx) + m.EffectiveSettings = vs +} + +// GetSettings returns the value of the Settings field in Endpoint as +// a postgres_tf.EndpointSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Endpoint) GetSettings(ctx context.Context) (postgres_tf.EndpointSettings, bool) { + var e postgres_tf.EndpointSettings + if m.Settings.IsNull() || m.Settings.IsUnknown() { + return e, false + } + var v postgres_tf.EndpointSettings + d := m.Settings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetSettings sets the value of the Settings field in Endpoint. +func (m *Endpoint) SetSettings(ctx context.Context, v postgres_tf.EndpointSettings) { + vs := v.ToObjectValue(ctx) + m.Settings = vs +} + +func (r *EndpointResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = autogen.GetDatabricksProductionName(resourceName) +} + +func (r *EndpointResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + attrs, blocks := tfschema.ResourceStructToSchemaMap(ctx, Endpoint{}, nil) + resp.Schema = schema.Schema{ + Description: "Terraform schema for Databricks postgres_endpoint", + Attributes: attrs, + Blocks: blocks, + } +} + +func (r *EndpointResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + r.Client = autogen.ConfigureResource(req, resp) +} + +func (r *EndpointResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var plan Endpoint + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + var endpoint postgres.Endpoint + + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, plan, &endpoint)...) + if resp.Diagnostics.HasError() { + return + } + + createRequest := postgres.CreateEndpointRequest{ + Endpoint: endpoint, + Parent: plan.Parent.ValueString(), + EndpointId: plan.EndpointId.ValueString(), + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + response, err := client.Postgres.CreateEndpoint(ctx, createRequest) + if err != nil { + resp.Diagnostics.AddError("failed to create postgres_endpoint", err.Error()) + return + } + + var newState Endpoint + + waitResponse, err := response.Wait(ctx) + if err != nil { + resp.Diagnostics.AddError("error waiting for postgres_endpoint to be ready", err.Error()) + return + } + + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, waitResponse, &newState)...) + + if resp.Diagnostics.HasError() { + return + } + + newState.SyncFieldsDuringCreateOrUpdate(ctx, plan) + + resp.Diagnostics.Append(resp.State.Set(ctx, newState)...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *EndpointResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var existingState Endpoint + resp.Diagnostics.Append(req.State.Get(ctx, &existingState)...) + if resp.Diagnostics.HasError() { + return + } + + var readRequest postgres.GetEndpointRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, existingState, &readRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + response, err := client.Postgres.GetEndpoint(ctx, readRequest) + if err != nil { + if apierr.IsMissing(err) { + resp.State.RemoveResource(ctx) + return + } + + resp.Diagnostics.AddError("failed to get postgres_endpoint", err.Error()) + return + } + + var newState Endpoint + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, response, &newState)...) + if resp.Diagnostics.HasError() { + return + } + + newState.SyncFieldsDuringRead(ctx, existingState) + + resp.Diagnostics.Append(resp.State.Set(ctx, newState)...) +} + +func (r *EndpointResource) update(ctx context.Context, plan Endpoint, diags *diag.Diagnostics, state *tfsdk.State) { + var endpoint postgres.Endpoint + + diags.Append(converters.TfSdkToGoSdkStruct(ctx, plan, &endpoint)...) + if diags.HasError() { + return + } + + updateRequest := postgres.UpdateEndpointRequest{ + Endpoint: endpoint, + Name: plan.Name.ValueString(), + UpdateMask: *fieldmask.New(strings.Split("autoscaling_limit_max_cu,autoscaling_limit_min_cu,disabled,pooler_mode,settings,suspend_timeout_duration", ",")), + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + diags.Append(clientDiags...) + if diags.HasError() { + return + } + response, err := client.Postgres.UpdateEndpoint(ctx, updateRequest) + if err != nil { + diags.AddError("failed to update postgres_endpoint", err.Error()) + return + } + + var newState Endpoint + + waitResponse, err := response.Wait(ctx) + if err != nil { + diags.AddError("error waiting for postgres_endpoint update", err.Error()) + return + } + + diags.Append(converters.GoSdkToTfSdkStruct(ctx, waitResponse, &newState)...) + + if diags.HasError() { + return + } + + newState.SyncFieldsDuringCreateOrUpdate(ctx, plan) + diags.Append(state.Set(ctx, newState)...) +} + +func (r *EndpointResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var plan Endpoint + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + r.update(ctx, plan, &resp.Diagnostics, &resp.State) +} + +func (r *EndpointResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var state Endpoint + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + var deleteRequest postgres.DeleteEndpointRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, state, &deleteRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + err := client.Postgres.DeleteEndpoint(ctx, deleteRequest) + if err != nil && !apierr.IsMissing(err) { + resp.Diagnostics.AddError("failed to delete postgres_endpoint", err.Error()) + return + } + +} + +var _ resource.ResourceWithImportState = &EndpointResource{} + +func (r *EndpointResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + parts := strings.Split(req.ID, ",") + + if len(parts) != 1 || parts[0] == "" { + resp.Diagnostics.AddError( + "Unexpected Import Identifier", + fmt.Sprintf( + "Expected import identifier with format: name. Got: %q", + req.ID, + ), + ) + return + } + + name := parts[0] + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), name)...) +} diff --git a/internal/providers/pluginfw/products/postgres_project/data_postgres_project.go b/internal/providers/pluginfw/products/postgres_project/data_postgres_project.go new file mode 100755 index 0000000000..c86f53289f --- /dev/null +++ b/internal/providers/pluginfw/products/postgres_project/data_postgres_project.go @@ -0,0 +1,229 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package postgres_project + +import ( + "context" + "reflect" + + "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/autogen" + pluginfwcontext "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/context" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/converters" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + "github.com/databricks/terraform-provider-databricks/internal/service/postgres_tf" + "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +const dataSourceName = "postgres_project" + +var _ datasource.DataSourceWithConfigure = &ProjectDataSource{} + +func DataSourceProject() datasource.DataSource { + return &ProjectDataSource{} +} + +type ProjectDataSource struct { + Client *autogen.DatabricksClient +} + +// ProjectData extends the main model with additional fields. +type ProjectData struct { + // The logical size limit for a branch. + BranchLogicalSizeLimitBytes types.Int64 `tfsdk:"branch_logical_size_limit_bytes"` + // The most recent time when any endpoint of this project was active. + ComputeLastActiveTime timetypes.RFC3339 `tfsdk:"compute_last_active_time"` + // A timestamp indicating when the project was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + + DefaultEndpointSettings types.Object `tfsdk:"default_endpoint_settings"` + // Human-readable project name. + DisplayName types.String `tfsdk:"display_name"` + + EffectiveDefaultEndpointSettings types.Object `tfsdk:"effective_default_endpoint_settings"` + + EffectiveDisplayName types.String `tfsdk:"effective_display_name"` + + EffectiveHistoryRetentionDuration timetypes.GoDuration `tfsdk:"effective_history_retention_duration"` + + EffectivePgVersion types.Int64 `tfsdk:"effective_pg_version"` + + EffectiveSettings types.Object `tfsdk:"effective_settings"` + // The number of seconds to retain the shared history for point in time + // recovery for all branches in this project. + HistoryRetentionDuration timetypes.GoDuration `tfsdk:"history_retention_duration"` + // The resource name of the project. Format: projects/{project_id} + Name types.String `tfsdk:"name"` + // The major Postgres version number. + PgVersion types.Int64 `tfsdk:"pg_version"` + + Settings types.Object `tfsdk:"settings"` + // The current space occupied by the project in storage. Synthetic storage + // size combines the logical data size and Write-Ahead Log (WAL) size for + // all branches in a project. + SyntheticStorageSizeBytes types.Int64 `tfsdk:"synthetic_storage_size_bytes"` + // System generated unique ID for the project. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the project was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in the extended +// ProjectData struct. 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 (m ProjectData) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "default_endpoint_settings": reflect.TypeOf(postgres_tf.ProjectDefaultEndpointSettings{}), + "effective_default_endpoint_settings": reflect.TypeOf(postgres_tf.ProjectDefaultEndpointSettings{}), + "effective_settings": reflect.TypeOf(postgres_tf.ProjectSettings{}), + "settings": reflect.TypeOf(postgres_tf.ProjectSettings{}), + } +} + +// ToObjectValue returns the object value for the resource, combining attributes from the +// embedded TFSDK model and contains additional fields. +// +// 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, ProjectData +// only implements ToObjectValue() and Type(). +func (m ProjectData) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "branch_logical_size_limit_bytes": m.BranchLogicalSizeLimitBytes, + "compute_last_active_time": m.ComputeLastActiveTime, + "create_time": m.CreateTime, + "default_endpoint_settings": m.DefaultEndpointSettings, + "display_name": m.DisplayName, + "effective_default_endpoint_settings": m.EffectiveDefaultEndpointSettings, + "effective_display_name": m.EffectiveDisplayName, + "effective_history_retention_duration": m.EffectiveHistoryRetentionDuration, + "effective_pg_version": m.EffectivePgVersion, + "effective_settings": m.EffectiveSettings, + "history_retention_duration": m.HistoryRetentionDuration, + "name": m.Name, + "pg_version": m.PgVersion, + "settings": m.Settings, + "synthetic_storage_size_bytes": m.SyntheticStorageSizeBytes, + "uid": m.Uid, + "update_time": m.UpdateTime, + }, + ) +} + +// Type returns the object type with attributes from both the embedded TFSDK model +// and contains additional fields. +func (m ProjectData) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "branch_logical_size_limit_bytes": types.Int64Type, + "compute_last_active_time": timetypes.RFC3339{}.Type(ctx), + "create_time": timetypes.RFC3339{}.Type(ctx), + "default_endpoint_settings": postgres_tf.ProjectDefaultEndpointSettings{}.Type(ctx), + "display_name": types.StringType, + "effective_default_endpoint_settings": postgres_tf.ProjectDefaultEndpointSettings{}.Type(ctx), + "effective_display_name": types.StringType, + "effective_history_retention_duration": timetypes.GoDuration{}.Type(ctx), + "effective_pg_version": types.Int64Type, + "effective_settings": postgres_tf.ProjectSettings{}.Type(ctx), + "history_retention_duration": timetypes.GoDuration{}.Type(ctx), + "name": types.StringType, + "pg_version": types.Int64Type, + "settings": postgres_tf.ProjectSettings{}.Type(ctx), + "synthetic_storage_size_bytes": types.Int64Type, + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +func (m ProjectData) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["branch_logical_size_limit_bytes"] = attrs["branch_logical_size_limit_bytes"].SetComputed() + attrs["compute_last_active_time"] = attrs["compute_last_active_time"].SetComputed() + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].SetComputed() + attrs["display_name"] = attrs["display_name"].SetComputed() + attrs["effective_default_endpoint_settings"] = attrs["effective_default_endpoint_settings"].SetComputed() + attrs["effective_display_name"] = attrs["effective_display_name"].SetComputed() + attrs["effective_history_retention_duration"] = attrs["effective_history_retention_duration"].SetComputed() + attrs["effective_pg_version"] = attrs["effective_pg_version"].SetComputed() + attrs["effective_settings"] = attrs["effective_settings"].SetComputed() + attrs["history_retention_duration"] = attrs["history_retention_duration"].SetComputed() + attrs["name"] = attrs["name"].SetRequired() + attrs["pg_version"] = attrs["pg_version"].SetComputed() + attrs["settings"] = attrs["settings"].SetComputed() + attrs["synthetic_storage_size_bytes"] = attrs["synthetic_storage_size_bytes"].SetComputed() + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + + return attrs +} + +func (r *ProjectDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = autogen.GetDatabricksProductionName(dataSourceName) +} + +func (r *ProjectDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + attrs, blocks := tfschema.DataSourceStructToSchemaMap(ctx, ProjectData{}, nil) + resp.Schema = schema.Schema{ + Description: "Terraform schema for Databricks Project", + Attributes: attrs, + Blocks: blocks, + } +} + +func (r *ProjectDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + r.Client = autogen.ConfigureDataSource(req, resp) +} + +func (r *ProjectDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + ctx = pluginfwcontext.SetUserAgentInDataSourceContext(ctx, dataSourceName) + + var config ProjectData + resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) + if resp.Diagnostics.HasError() { + return + } + + var readRequest postgres.GetProjectRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, config, &readRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + response, err := client.Postgres.GetProject(ctx, readRequest) + if err != nil { + if apierr.IsMissing(err) { + resp.State.RemoveResource(ctx) + return + } + + resp.Diagnostics.AddError("failed to get postgres_project", err.Error()) + return + } + + var newState ProjectData + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, response, &newState)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, newState)...) +} diff --git a/internal/providers/pluginfw/products/postgres_project/data_postgres_projects.go b/internal/providers/pluginfw/products/postgres_project/data_postgres_projects.go new file mode 100755 index 0000000000..27d5d60dfd --- /dev/null +++ b/internal/providers/pluginfw/products/postgres_project/data_postgres_projects.go @@ -0,0 +1,109 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package postgres_project + +import ( + "context" + "reflect" + + "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/autogen" + pluginfwcontext "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/context" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/converters" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +const dataSourcesName = "postgres_projects" + +var _ datasource.DataSourceWithConfigure = &ProjectsDataSource{} + +func DataSourceProjects() datasource.DataSource { + return &ProjectsDataSource{} +} + +// ProjectsData extends the main model with additional fields. +type ProjectsData struct { + Postgres types.List `tfsdk:"projects"` + // Upper bound for items returned. + PageSize types.Int64 `tfsdk:"page_size"` +} + +func (ProjectsData) GetComplexFieldTypes(context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "projects": reflect.TypeOf(ProjectData{}), + } +} + +func (m ProjectsData) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["page_size"] = attrs["page_size"].SetOptional() + + attrs["projects"] = attrs["projects"].SetComputed() + return attrs +} + +type ProjectsDataSource struct { + Client *autogen.DatabricksClient +} + +func (r *ProjectsDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = autogen.GetDatabricksProductionName(dataSourcesName) +} + +func (r *ProjectsDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + attrs, blocks := tfschema.DataSourceStructToSchemaMap(ctx, ProjectsData{}, nil) + resp.Schema = schema.Schema{ + Description: "Terraform schema for Databricks Project", + Attributes: attrs, + Blocks: blocks, + } +} + +func (r *ProjectsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + r.Client = autogen.ConfigureDataSource(req, resp) +} + +func (r *ProjectsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + ctx = pluginfwcontext.SetUserAgentInDataSourceContext(ctx, dataSourcesName) + + var config ProjectsData + resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) + if resp.Diagnostics.HasError() { + return + } + + var listRequest postgres.ListProjectsRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, config, &listRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + response, err := client.Postgres.ListProjectsAll(ctx, listRequest) + if err != nil { + resp.Diagnostics.AddError("failed to list postgres_projects", err.Error()) + return + } + + var results = []attr.Value{} + for _, item := range response { + var project ProjectData + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, item, &project)...) + if resp.Diagnostics.HasError() { + return + } + results = append(results, project.ToObjectValue(ctx)) + } + + config.Postgres = types.ListValueMust(ProjectData{}.Type(ctx), results) + resp.Diagnostics.Append(resp.State.Set(ctx, config)...) +} diff --git a/internal/providers/pluginfw/products/postgres_project/resource_postgres_project.go b/internal/providers/pluginfw/products/postgres_project/resource_postgres_project.go new file mode 100755 index 0000000000..46445dc66d --- /dev/null +++ b/internal/providers/pluginfw/products/postgres_project/resource_postgres_project.go @@ -0,0 +1,624 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package postgres_project + +import ( + "context" + "fmt" + "reflect" + "strings" + + "github.com/databricks/databricks-sdk-go/apierr" + "github.com/databricks/databricks-sdk-go/common/types/fieldmask" + "github.com/databricks/databricks-sdk-go/service/postgres" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/autogen" + pluginfwcommon "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/common" + pluginfwcontext "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/context" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/converters" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + "github.com/databricks/terraform-provider-databricks/internal/service/postgres_tf" + "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +const resourceName = "postgres_project" + +var _ resource.ResourceWithConfigure = &ProjectResource{} + +func ResourceProject() resource.Resource { + return &ProjectResource{} +} + +type ProjectResource struct { + Client *autogen.DatabricksClient +} + +// Project extends the main model with additional fields. +type Project struct { + // The logical size limit for a branch. + BranchLogicalSizeLimitBytes types.Int64 `tfsdk:"branch_logical_size_limit_bytes"` + // The most recent time when any endpoint of this project was active. + ComputeLastActiveTime timetypes.RFC3339 `tfsdk:"compute_last_active_time"` + // A timestamp indicating when the project was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + + DefaultEndpointSettings types.Object `tfsdk:"default_endpoint_settings"` + // Human-readable project name. + DisplayName types.String `tfsdk:"display_name"` + + EffectiveDefaultEndpointSettings types.Object `tfsdk:"effective_default_endpoint_settings"` + + EffectiveDisplayName types.String `tfsdk:"effective_display_name"` + + EffectiveHistoryRetentionDuration timetypes.GoDuration `tfsdk:"effective_history_retention_duration"` + + EffectivePgVersion types.Int64 `tfsdk:"effective_pg_version"` + + EffectiveSettings types.Object `tfsdk:"effective_settings"` + // The number of seconds to retain the shared history for point in time + // recovery for all branches in this project. + HistoryRetentionDuration timetypes.GoDuration `tfsdk:"history_retention_duration"` + // The resource name of the project. Format: projects/{project_id} + Name types.String `tfsdk:"name"` + // The major Postgres version number. + PgVersion types.Int64 `tfsdk:"pg_version"` + // The ID to use for the Project, which will become the final component of + // the project's resource name. + // + // This value should be 4-63 characters, and valid characters are + // /[a-z][0-9]-/. + ProjectId types.String `tfsdk:"project_id"` + + Settings types.Object `tfsdk:"settings"` + // The current space occupied by the project in storage. Synthetic storage + // size combines the logical data size and Write-Ahead Log (WAL) size for + // all branches in a project. + SyntheticStorageSizeBytes types.Int64 `tfsdk:"synthetic_storage_size_bytes"` + // System generated unique ID for the project. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the project was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in the extended +// Project struct. 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 (m Project) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "default_endpoint_settings": reflect.TypeOf(postgres_tf.ProjectDefaultEndpointSettings{}), + "effective_default_endpoint_settings": reflect.TypeOf(postgres_tf.ProjectDefaultEndpointSettings{}), + "effective_settings": reflect.TypeOf(postgres_tf.ProjectSettings{}), + "settings": reflect.TypeOf(postgres_tf.ProjectSettings{}), + } +} + +// ToObjectValue returns the object value for the resource, combining attributes from the +// embedded TFSDK model and contains additional fields. +// +// 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, Project +// only implements ToObjectValue() and Type(). +func (m Project) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{"branch_logical_size_limit_bytes": m.BranchLogicalSizeLimitBytes, + "compute_last_active_time": m.ComputeLastActiveTime, + "create_time": m.CreateTime, + "default_endpoint_settings": m.DefaultEndpointSettings, + "display_name": m.DisplayName, + "effective_default_endpoint_settings": m.EffectiveDefaultEndpointSettings, + "effective_display_name": m.EffectiveDisplayName, + "effective_history_retention_duration": m.EffectiveHistoryRetentionDuration, + "effective_pg_version": m.EffectivePgVersion, + "effective_settings": m.EffectiveSettings, + "history_retention_duration": m.HistoryRetentionDuration, + "name": m.Name, + "pg_version": m.PgVersion, + "project_id": m.ProjectId, + "settings": m.Settings, + "synthetic_storage_size_bytes": m.SyntheticStorageSizeBytes, + "uid": m.Uid, + "update_time": m.UpdateTime, + }, + ) +} + +// Type returns the object type with attributes from both the embedded TFSDK model +// and contains additional fields. +func (m Project) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{"branch_logical_size_limit_bytes": types.Int64Type, + "compute_last_active_time": timetypes.RFC3339{}.Type(ctx), + "create_time": timetypes.RFC3339{}.Type(ctx), + "default_endpoint_settings": postgres_tf.ProjectDefaultEndpointSettings{}.Type(ctx), + "display_name": types.StringType, + "effective_default_endpoint_settings": postgres_tf.ProjectDefaultEndpointSettings{}.Type(ctx), + "effective_display_name": types.StringType, + "effective_history_retention_duration": timetypes.GoDuration{}.Type(ctx), + "effective_pg_version": types.Int64Type, + "effective_settings": postgres_tf.ProjectSettings{}.Type(ctx), + "history_retention_duration": timetypes.GoDuration{}.Type(ctx), + "name": types.StringType, + "pg_version": types.Int64Type, + "project_id": types.StringType, + "settings": postgres_tf.ProjectSettings{}.Type(ctx), + "synthetic_storage_size_bytes": types.Int64Type, + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +// SyncFieldsDuringCreateOrUpdate copies values from the plan into the receiver, +// including both embedded model fields and additional fields. This method is called +// during create and update. +func (to *Project) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Project) { + if !from.DefaultEndpointSettings.IsUnknown() && !from.DefaultEndpointSettings.IsNull() { + // DefaultEndpointSettings is an input only field and not returned by the service, so we keep the value from the prior state. + to.DefaultEndpointSettings = from.DefaultEndpointSettings + } + if !from.DefaultEndpointSettings.IsNull() && !from.DefaultEndpointSettings.IsUnknown() { + if toDefaultEndpointSettings, ok := to.GetDefaultEndpointSettings(ctx); ok { + if fromDefaultEndpointSettings, ok := from.GetDefaultEndpointSettings(ctx); ok { + // Recursively sync the fields of DefaultEndpointSettings + toDefaultEndpointSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromDefaultEndpointSettings) + to.SetDefaultEndpointSettings(ctx, toDefaultEndpointSettings) + } + } + } + if !from.DisplayName.IsUnknown() && !from.DisplayName.IsNull() { + // DisplayName is an input only field and not returned by the service, so we keep the value from the prior state. + to.DisplayName = from.DisplayName + } + if !from.EffectiveDefaultEndpointSettings.IsNull() && !from.EffectiveDefaultEndpointSettings.IsUnknown() { + if toEffectiveDefaultEndpointSettings, ok := to.GetEffectiveDefaultEndpointSettings(ctx); ok { + if fromEffectiveDefaultEndpointSettings, ok := from.GetEffectiveDefaultEndpointSettings(ctx); ok { + // Recursively sync the fields of EffectiveDefaultEndpointSettings + toEffectiveDefaultEndpointSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromEffectiveDefaultEndpointSettings) + to.SetEffectiveDefaultEndpointSettings(ctx, toEffectiveDefaultEndpointSettings) + } + } + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + // Recursively sync the fields of EffectiveSettings + toEffectiveSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + if !from.HistoryRetentionDuration.IsUnknown() && !from.HistoryRetentionDuration.IsNull() { + // HistoryRetentionDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.HistoryRetentionDuration = from.HistoryRetentionDuration + } + to.ProjectId = from.ProjectId + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + // Recursively sync the fields of Settings + toSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } +} + +// SyncFieldsDuringRead copies values from the existing state into the receiver, +// including both embedded model fields and additional fields. This method is called +// during read. +func (to *Project) SyncFieldsDuringRead(ctx context.Context, from Project) { + if !from.DefaultEndpointSettings.IsUnknown() && !from.DefaultEndpointSettings.IsNull() { + // DefaultEndpointSettings is an input only field and not returned by the service, so we keep the value from the prior state. + to.DefaultEndpointSettings = from.DefaultEndpointSettings + } + if !from.DefaultEndpointSettings.IsNull() && !from.DefaultEndpointSettings.IsUnknown() { + if toDefaultEndpointSettings, ok := to.GetDefaultEndpointSettings(ctx); ok { + if fromDefaultEndpointSettings, ok := from.GetDefaultEndpointSettings(ctx); ok { + toDefaultEndpointSettings.SyncFieldsDuringRead(ctx, fromDefaultEndpointSettings) + to.SetDefaultEndpointSettings(ctx, toDefaultEndpointSettings) + } + } + } + if !from.DisplayName.IsUnknown() && !from.DisplayName.IsNull() { + // DisplayName is an input only field and not returned by the service, so we keep the value from the prior state. + to.DisplayName = from.DisplayName + } + if !from.EffectiveDefaultEndpointSettings.IsNull() && !from.EffectiveDefaultEndpointSettings.IsUnknown() { + if toEffectiveDefaultEndpointSettings, ok := to.GetEffectiveDefaultEndpointSettings(ctx); ok { + if fromEffectiveDefaultEndpointSettings, ok := from.GetEffectiveDefaultEndpointSettings(ctx); ok { + toEffectiveDefaultEndpointSettings.SyncFieldsDuringRead(ctx, fromEffectiveDefaultEndpointSettings) + to.SetEffectiveDefaultEndpointSettings(ctx, toEffectiveDefaultEndpointSettings) + } + } + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + toEffectiveSettings.SyncFieldsDuringRead(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + if !from.HistoryRetentionDuration.IsUnknown() && !from.HistoryRetentionDuration.IsNull() { + // HistoryRetentionDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.HistoryRetentionDuration = from.HistoryRetentionDuration + } + to.ProjectId = from.ProjectId + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + toSettings.SyncFieldsDuringRead(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } +} + +func (m Project) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["branch_logical_size_limit_bytes"] = attrs["branch_logical_size_limit_bytes"].SetComputed() + attrs["compute_last_active_time"] = attrs["compute_last_active_time"].SetComputed() + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].SetOptional() + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].SetComputed() + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].(tfschema.SingleNestedAttributeBuilder).AddPlanModifier(objectplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["display_name"] = attrs["display_name"].SetOptional() + attrs["display_name"] = attrs["display_name"].SetComputed() + attrs["display_name"] = attrs["display_name"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["effective_default_endpoint_settings"] = attrs["effective_default_endpoint_settings"].SetComputed() + attrs["effective_display_name"] = attrs["effective_display_name"].SetComputed() + attrs["effective_history_retention_duration"] = attrs["effective_history_retention_duration"].SetComputed() + attrs["effective_pg_version"] = attrs["effective_pg_version"].SetComputed() + attrs["effective_settings"] = attrs["effective_settings"].SetComputed() + attrs["history_retention_duration"] = attrs["history_retention_duration"].SetOptional() + attrs["history_retention_duration"] = attrs["history_retention_duration"].SetComputed() + attrs["history_retention_duration"] = attrs["history_retention_duration"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["name"] = attrs["name"].SetComputed() + attrs["pg_version"] = attrs["pg_version"].SetOptional() + attrs["pg_version"] = attrs["pg_version"].(tfschema.Int64AttributeBuilder).AddPlanModifier(int64planmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["settings"] = attrs["settings"].SetOptional() + attrs["synthetic_storage_size_bytes"] = attrs["synthetic_storage_size_bytes"].SetComputed() + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + attrs["project_id"] = attrs["project_id"].SetComputed() + attrs["project_id"] = attrs["project_id"].SetOptional() + attrs["project_id"] = attrs["project_id"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + + attrs["name"] = attrs["name"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + return attrs +} + +// GetDefaultEndpointSettings returns the value of the DefaultEndpointSettings field in Project as +// a postgres_tf.ProjectDefaultEndpointSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project) GetDefaultEndpointSettings(ctx context.Context) (postgres_tf.ProjectDefaultEndpointSettings, bool) { + var e postgres_tf.ProjectDefaultEndpointSettings + if m.DefaultEndpointSettings.IsNull() || m.DefaultEndpointSettings.IsUnknown() { + return e, false + } + var v postgres_tf.ProjectDefaultEndpointSettings + d := m.DefaultEndpointSettings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetDefaultEndpointSettings sets the value of the DefaultEndpointSettings field in Project. +func (m *Project) SetDefaultEndpointSettings(ctx context.Context, v postgres_tf.ProjectDefaultEndpointSettings) { + vs := v.ToObjectValue(ctx) + m.DefaultEndpointSettings = vs +} + +// GetEffectiveDefaultEndpointSettings returns the value of the EffectiveDefaultEndpointSettings field in Project as +// a postgres_tf.ProjectDefaultEndpointSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project) GetEffectiveDefaultEndpointSettings(ctx context.Context) (postgres_tf.ProjectDefaultEndpointSettings, bool) { + var e postgres_tf.ProjectDefaultEndpointSettings + if m.EffectiveDefaultEndpointSettings.IsNull() || m.EffectiveDefaultEndpointSettings.IsUnknown() { + return e, false + } + var v postgres_tf.ProjectDefaultEndpointSettings + d := m.EffectiveDefaultEndpointSettings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetEffectiveDefaultEndpointSettings sets the value of the EffectiveDefaultEndpointSettings field in Project. +func (m *Project) SetEffectiveDefaultEndpointSettings(ctx context.Context, v postgres_tf.ProjectDefaultEndpointSettings) { + vs := v.ToObjectValue(ctx) + m.EffectiveDefaultEndpointSettings = vs +} + +// GetEffectiveSettings returns the value of the EffectiveSettings field in Project as +// a postgres_tf.ProjectSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project) GetEffectiveSettings(ctx context.Context) (postgres_tf.ProjectSettings, bool) { + var e postgres_tf.ProjectSettings + if m.EffectiveSettings.IsNull() || m.EffectiveSettings.IsUnknown() { + return e, false + } + var v postgres_tf.ProjectSettings + d := m.EffectiveSettings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetEffectiveSettings sets the value of the EffectiveSettings field in Project. +func (m *Project) SetEffectiveSettings(ctx context.Context, v postgres_tf.ProjectSettings) { + vs := v.ToObjectValue(ctx) + m.EffectiveSettings = vs +} + +// GetSettings returns the value of the Settings field in Project as +// a postgres_tf.ProjectSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project) GetSettings(ctx context.Context) (postgres_tf.ProjectSettings, bool) { + var e postgres_tf.ProjectSettings + if m.Settings.IsNull() || m.Settings.IsUnknown() { + return e, false + } + var v postgres_tf.ProjectSettings + d := m.Settings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetSettings sets the value of the Settings field in Project. +func (m *Project) SetSettings(ctx context.Context, v postgres_tf.ProjectSettings) { + vs := v.ToObjectValue(ctx) + m.Settings = vs +} + +func (r *ProjectResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = autogen.GetDatabricksProductionName(resourceName) +} + +func (r *ProjectResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + attrs, blocks := tfschema.ResourceStructToSchemaMap(ctx, Project{}, nil) + resp.Schema = schema.Schema{ + Description: "Terraform schema for Databricks postgres_project", + Attributes: attrs, + Blocks: blocks, + } +} + +func (r *ProjectResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + r.Client = autogen.ConfigureResource(req, resp) +} + +func (r *ProjectResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var plan Project + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + var project postgres.Project + + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, plan, &project)...) + if resp.Diagnostics.HasError() { + return + } + + createRequest := postgres.CreateProjectRequest{ + Project: project, + ProjectId: plan.ProjectId.ValueString(), + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + response, err := client.Postgres.CreateProject(ctx, createRequest) + if err != nil { + resp.Diagnostics.AddError("failed to create postgres_project", err.Error()) + return + } + + var newState Project + + waitResponse, err := response.Wait(ctx) + if err != nil { + resp.Diagnostics.AddError("error waiting for postgres_project to be ready", err.Error()) + return + } + + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, waitResponse, &newState)...) + + if resp.Diagnostics.HasError() { + return + } + + newState.SyncFieldsDuringCreateOrUpdate(ctx, plan) + + resp.Diagnostics.Append(resp.State.Set(ctx, newState)...) + if resp.Diagnostics.HasError() { + return + } +} + +func (r *ProjectResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var existingState Project + resp.Diagnostics.Append(req.State.Get(ctx, &existingState)...) + if resp.Diagnostics.HasError() { + return + } + + var readRequest postgres.GetProjectRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, existingState, &readRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + response, err := client.Postgres.GetProject(ctx, readRequest) + if err != nil { + if apierr.IsMissing(err) { + resp.State.RemoveResource(ctx) + return + } + + resp.Diagnostics.AddError("failed to get postgres_project", err.Error()) + return + } + + var newState Project + resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, response, &newState)...) + if resp.Diagnostics.HasError() { + return + } + + newState.SyncFieldsDuringRead(ctx, existingState) + + resp.Diagnostics.Append(resp.State.Set(ctx, newState)...) +} + +func (r *ProjectResource) update(ctx context.Context, plan Project, diags *diag.Diagnostics, state *tfsdk.State) { + var project postgres.Project + + diags.Append(converters.TfSdkToGoSdkStruct(ctx, plan, &project)...) + if diags.HasError() { + return + } + + updateRequest := postgres.UpdateProjectRequest{ + Project: project, + Name: plan.Name.ValueString(), + UpdateMask: *fieldmask.New(strings.Split("default_endpoint_settings,display_name,history_retention_duration,settings", ",")), + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + diags.Append(clientDiags...) + if diags.HasError() { + return + } + response, err := client.Postgres.UpdateProject(ctx, updateRequest) + if err != nil { + diags.AddError("failed to update postgres_project", err.Error()) + return + } + + var newState Project + + waitResponse, err := response.Wait(ctx) + if err != nil { + diags.AddError("error waiting for postgres_project update", err.Error()) + return + } + + diags.Append(converters.GoSdkToTfSdkStruct(ctx, waitResponse, &newState)...) + + if diags.HasError() { + return + } + + newState.SyncFieldsDuringCreateOrUpdate(ctx, plan) + diags.Append(state.Set(ctx, newState)...) +} + +func (r *ProjectResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var plan Project + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + r.update(ctx, plan, &resp.Diagnostics, &resp.State) +} + +func (r *ProjectResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + ctx = pluginfwcontext.SetUserAgentInResourceContext(ctx, resourceName) + + var state Project + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + var deleteRequest postgres.DeleteProjectRequest + resp.Diagnostics.Append(converters.TfSdkToGoSdkStruct(ctx, state, &deleteRequest)...) + if resp.Diagnostics.HasError() { + return + } + + client, clientDiags := r.Client.GetWorkspaceClient() + + resp.Diagnostics.Append(clientDiags...) + if resp.Diagnostics.HasError() { + return + } + + err := client.Postgres.DeleteProject(ctx, deleteRequest) + if err != nil && !apierr.IsMissing(err) { + resp.Diagnostics.AddError("failed to delete postgres_project", err.Error()) + return + } + +} + +var _ resource.ResourceWithImportState = &ProjectResource{} + +func (r *ProjectResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + parts := strings.Split(req.ID, ",") + + if len(parts) != 1 || parts[0] == "" { + resp.Diagnostics.AddError( + "Unexpected Import Identifier", + fmt.Sprintf( + "Expected import identifier with format: name. Got: %q", + req.ID, + ), + ) + return + } + + name := parts[0] + resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), name)...) +} diff --git a/internal/service/apps_tf/legacy_model.go b/internal/service/apps_tf/legacy_model.go index 72bfddb4d9..5d66103be2 100755 --- a/internal/service/apps_tf/legacy_model.go +++ b/internal/service/apps_tf/legacy_model.go @@ -47,6 +47,8 @@ type App_SdkV2 struct { Description types.String `tfsdk:"description"` EffectiveBudgetPolicyId types.String `tfsdk:"effective_budget_policy_id"` + + EffectiveUsagePolicyId types.String `tfsdk:"effective_usage_policy_id"` // The effective api scopes granted to the user access token. EffectiveUserApiScopes types.List `tfsdk:"effective_user_api_scopes"` // The unique identifier of the app. @@ -76,6 +78,8 @@ type App_SdkV2 struct { // The URL of the app once it is deployed. Url types.String `tfsdk:"url"` + UsagePolicyId types.String `tfsdk:"usage_policy_id"` + UserApiScopes types.List `tfsdk:"user_api_scopes"` } @@ -203,6 +207,7 @@ func (m App_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.Attribute attrs["default_source_code_path"] = attrs["default_source_code_path"].SetComputed() attrs["description"] = attrs["description"].SetOptional() attrs["effective_budget_policy_id"] = attrs["effective_budget_policy_id"].SetComputed() + attrs["effective_usage_policy_id"] = attrs["effective_usage_policy_id"].SetComputed() attrs["effective_user_api_scopes"] = attrs["effective_user_api_scopes"].SetComputed() attrs["id"] = attrs["id"].SetComputed() attrs["name"] = attrs["name"].SetRequired() @@ -217,6 +222,7 @@ func (m App_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.Attribute attrs["update_time"] = attrs["update_time"].SetComputed() attrs["updater"] = attrs["updater"].SetComputed() attrs["url"] = attrs["url"].SetComputed() + attrs["usage_policy_id"] = attrs["usage_policy_id"].SetOptional() attrs["user_api_scopes"] = attrs["user_api_scopes"].SetOptional() return attrs @@ -258,6 +264,7 @@ func (m App_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "default_source_code_path": m.DefaultSourceCodePath, "description": m.Description, "effective_budget_policy_id": m.EffectiveBudgetPolicyId, + "effective_usage_policy_id": m.EffectiveUsagePolicyId, "effective_user_api_scopes": m.EffectiveUserApiScopes, "id": m.Id, "name": m.Name, @@ -271,6 +278,7 @@ func (m App_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "update_time": m.UpdateTime, "updater": m.Updater, "url": m.Url, + "usage_policy_id": m.UsagePolicyId, "user_api_scopes": m.UserApiScopes, }) } @@ -295,6 +303,7 @@ func (m App_SdkV2) Type(ctx context.Context) attr.Type { "default_source_code_path": types.StringType, "description": types.StringType, "effective_budget_policy_id": types.StringType, + "effective_usage_policy_id": types.StringType, "effective_user_api_scopes": basetypes.ListType{ ElemType: types.StringType, }, @@ -314,6 +323,7 @@ func (m App_SdkV2) Type(ctx context.Context) attr.Type { "update_time": types.StringType, "updater": types.StringType, "url": types.StringType, + "usage_policy_id": types.StringType, "user_api_scopes": basetypes.ListType{ ElemType: types.StringType, }, diff --git a/internal/service/apps_tf/model.go b/internal/service/apps_tf/model.go index d044c8b69e..817ab16d35 100755 --- a/internal/service/apps_tf/model.go +++ b/internal/service/apps_tf/model.go @@ -46,6 +46,8 @@ type App struct { Description types.String `tfsdk:"description"` EffectiveBudgetPolicyId types.String `tfsdk:"effective_budget_policy_id"` + + EffectiveUsagePolicyId types.String `tfsdk:"effective_usage_policy_id"` // The effective api scopes granted to the user access token. EffectiveUserApiScopes types.List `tfsdk:"effective_user_api_scopes"` // The unique identifier of the app. @@ -75,6 +77,8 @@ type App struct { // The URL of the app once it is deployed. Url types.String `tfsdk:"url"` + UsagePolicyId types.String `tfsdk:"usage_policy_id"` + UserApiScopes types.List `tfsdk:"user_api_scopes"` } @@ -199,6 +203,7 @@ func (m App) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilde attrs["default_source_code_path"] = attrs["default_source_code_path"].SetComputed() attrs["description"] = attrs["description"].SetOptional() attrs["effective_budget_policy_id"] = attrs["effective_budget_policy_id"].SetComputed() + attrs["effective_usage_policy_id"] = attrs["effective_usage_policy_id"].SetComputed() attrs["effective_user_api_scopes"] = attrs["effective_user_api_scopes"].SetComputed() attrs["id"] = attrs["id"].SetComputed() attrs["name"] = attrs["name"].SetRequired() @@ -212,6 +217,7 @@ func (m App) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilde attrs["update_time"] = attrs["update_time"].SetComputed() attrs["updater"] = attrs["updater"].SetComputed() attrs["url"] = attrs["url"].SetComputed() + attrs["usage_policy_id"] = attrs["usage_policy_id"].SetOptional() attrs["user_api_scopes"] = attrs["user_api_scopes"].SetOptional() return attrs @@ -253,6 +259,7 @@ func (m App) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "default_source_code_path": m.DefaultSourceCodePath, "description": m.Description, "effective_budget_policy_id": m.EffectiveBudgetPolicyId, + "effective_usage_policy_id": m.EffectiveUsagePolicyId, "effective_user_api_scopes": m.EffectiveUserApiScopes, "id": m.Id, "name": m.Name, @@ -266,6 +273,7 @@ func (m App) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "update_time": m.UpdateTime, "updater": m.Updater, "url": m.Url, + "usage_policy_id": m.UsagePolicyId, "user_api_scopes": m.UserApiScopes, }) } @@ -284,6 +292,7 @@ func (m App) Type(ctx context.Context) attr.Type { "default_source_code_path": types.StringType, "description": types.StringType, "effective_budget_policy_id": types.StringType, + "effective_usage_policy_id": types.StringType, "effective_user_api_scopes": basetypes.ListType{ ElemType: types.StringType, }, @@ -301,6 +310,7 @@ func (m App) Type(ctx context.Context) attr.Type { "update_time": types.StringType, "updater": types.StringType, "url": types.StringType, + "usage_policy_id": types.StringType, "user_api_scopes": basetypes.ListType{ ElemType: types.StringType, }, diff --git a/internal/service/catalog_tf/legacy_model.go b/internal/service/catalog_tf/legacy_model.go index 548fb3e395..eda3433792 100755 --- a/internal/service/catalog_tf/legacy_model.go +++ b/internal/service/catalog_tf/legacy_model.go @@ -4467,6 +4467,9 @@ func (m *CreateAccessRequestResponse_SdkV2) SetRequestDestinations(ctx context.C } type CreateAccountsMetastore_SdkV2 struct { + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled types.Bool `tfsdk:"external_access_enabled"` // The user-specified name of the metastore. Name types.String `tfsdk:"name"` // Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). @@ -4482,6 +4485,7 @@ func (to *CreateAccountsMetastore_SdkV2) SyncFieldsDuringRead(ctx context.Contex } func (m CreateAccountsMetastore_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["external_access_enabled"] = attrs["external_access_enabled"].SetOptional() attrs["name"] = attrs["name"].SetRequired() attrs["region"] = attrs["region"].SetOptional() attrs["storage_root"] = attrs["storage_root"].SetOptional() @@ -4507,9 +4511,10 @@ func (m CreateAccountsMetastore_SdkV2) ToObjectValue(ctx context.Context) basety return types.ObjectValueMust( m.Type(ctx).(basetypes.ObjectType).AttrTypes, map[string]attr.Value{ - "name": m.Name, - "region": m.Region, - "storage_root": m.StorageRoot, + "external_access_enabled": m.ExternalAccessEnabled, + "name": m.Name, + "region": m.Region, + "storage_root": m.StorageRoot, }) } @@ -4517,9 +4522,10 @@ func (m CreateAccountsMetastore_SdkV2) ToObjectValue(ctx context.Context) basety func (m CreateAccountsMetastore_SdkV2) Type(ctx context.Context) attr.Type { return types.ObjectType{ AttrTypes: map[string]attr.Type{ - "name": types.StringType, - "region": types.StringType, - "storage_root": types.StringType, + "external_access_enabled": types.BoolType, + "name": types.StringType, + "region": types.StringType, + "storage_root": types.StringType, }, } } @@ -6270,6 +6276,9 @@ func (m *CreateFunctionRequest_SdkV2) SetFunctionInfo(ctx context.Context, v Cre } type CreateMetastore_SdkV2 struct { + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled types.Bool `tfsdk:"external_access_enabled"` // The user-specified name of the metastore. Name types.String `tfsdk:"name"` // Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). @@ -6285,6 +6294,7 @@ func (to *CreateMetastore_SdkV2) SyncFieldsDuringRead(ctx context.Context, from } func (m CreateMetastore_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["external_access_enabled"] = attrs["external_access_enabled"].SetOptional() attrs["name"] = attrs["name"].SetRequired() attrs["region"] = attrs["region"].SetOptional() attrs["storage_root"] = attrs["storage_root"].SetOptional() @@ -6310,9 +6320,10 @@ func (m CreateMetastore_SdkV2) ToObjectValue(ctx context.Context) basetypes.Obje return types.ObjectValueMust( m.Type(ctx).(basetypes.ObjectType).AttrTypes, map[string]attr.Value{ - "name": m.Name, - "region": m.Region, - "storage_root": m.StorageRoot, + "external_access_enabled": m.ExternalAccessEnabled, + "name": m.Name, + "region": m.Region, + "storage_root": m.StorageRoot, }) } @@ -6320,9 +6331,10 @@ func (m CreateMetastore_SdkV2) ToObjectValue(ctx context.Context) basetypes.Obje func (m CreateMetastore_SdkV2) Type(ctx context.Context) attr.Type { return types.ObjectType{ AttrTypes: map[string]attr.Type{ - "name": types.StringType, - "region": types.StringType, - "storage_root": types.StringType, + "external_access_enabled": types.BoolType, + "name": types.StringType, + "region": types.StringType, + "storage_root": types.StringType, }, } } @@ -29082,6 +29094,9 @@ type UpdateAccountsMetastore_SdkV2 struct { DeltaSharingRecipientTokenLifetimeInSeconds types.Int64 `tfsdk:"delta_sharing_recipient_token_lifetime_in_seconds"` // The scope of Delta Sharing enabled for the metastore. DeltaSharingScope types.String `tfsdk:"delta_sharing_scope"` + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled types.Bool `tfsdk:"external_access_enabled"` // The owner of the metastore. Owner types.String `tfsdk:"owner"` // Privilege model version of the metastore, of the form `major.minor` @@ -29101,6 +29116,7 @@ func (m UpdateAccountsMetastore_SdkV2) ApplySchemaCustomizations(attrs map[strin attrs["delta_sharing_organization_name"] = attrs["delta_sharing_organization_name"].SetOptional() attrs["delta_sharing_recipient_token_lifetime_in_seconds"] = attrs["delta_sharing_recipient_token_lifetime_in_seconds"].SetOptional() attrs["delta_sharing_scope"] = attrs["delta_sharing_scope"].SetOptional() + attrs["external_access_enabled"] = attrs["external_access_enabled"].SetOptional() attrs["owner"] = attrs["owner"].SetOptional() attrs["privilege_model_version"] = attrs["privilege_model_version"].SetOptional() attrs["storage_root_credential_id"] = attrs["storage_root_credential_id"].SetOptional() @@ -29129,6 +29145,7 @@ func (m UpdateAccountsMetastore_SdkV2) ToObjectValue(ctx context.Context) basety "delta_sharing_organization_name": m.DeltaSharingOrganizationName, "delta_sharing_recipient_token_lifetime_in_seconds": m.DeltaSharingRecipientTokenLifetimeInSeconds, "delta_sharing_scope": m.DeltaSharingScope, + "external_access_enabled": m.ExternalAccessEnabled, "owner": m.Owner, "privilege_model_version": m.PrivilegeModelVersion, "storage_root_credential_id": m.StorageRootCredentialId, @@ -29142,6 +29159,7 @@ func (m UpdateAccountsMetastore_SdkV2) Type(ctx context.Context) attr.Type { "delta_sharing_organization_name": types.StringType, "delta_sharing_recipient_token_lifetime_in_seconds": types.Int64Type, "delta_sharing_scope": types.StringType, + "external_access_enabled": types.BoolType, "owner": types.StringType, "privilege_model_version": types.StringType, "storage_root_credential_id": types.StringType, @@ -30770,6 +30788,9 @@ type UpdateMetastore_SdkV2 struct { DeltaSharingRecipientTokenLifetimeInSeconds types.Int64 `tfsdk:"delta_sharing_recipient_token_lifetime_in_seconds"` // The scope of Delta Sharing enabled for the metastore. DeltaSharingScope types.String `tfsdk:"delta_sharing_scope"` + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled types.Bool `tfsdk:"external_access_enabled"` // Unique ID of the metastore. Id types.String `tfsdk:"-"` // New name for the metastore. @@ -30793,6 +30814,7 @@ func (m UpdateMetastore_SdkV2) ApplySchemaCustomizations(attrs map[string]tfsche attrs["delta_sharing_organization_name"] = attrs["delta_sharing_organization_name"].SetOptional() attrs["delta_sharing_recipient_token_lifetime_in_seconds"] = attrs["delta_sharing_recipient_token_lifetime_in_seconds"].SetOptional() attrs["delta_sharing_scope"] = attrs["delta_sharing_scope"].SetOptional() + attrs["external_access_enabled"] = attrs["external_access_enabled"].SetOptional() attrs["new_name"] = attrs["new_name"].SetOptional() attrs["owner"] = attrs["owner"].SetOptional() attrs["privilege_model_version"] = attrs["privilege_model_version"].SetOptional() @@ -30823,6 +30845,7 @@ func (m UpdateMetastore_SdkV2) ToObjectValue(ctx context.Context) basetypes.Obje "delta_sharing_organization_name": m.DeltaSharingOrganizationName, "delta_sharing_recipient_token_lifetime_in_seconds": m.DeltaSharingRecipientTokenLifetimeInSeconds, "delta_sharing_scope": m.DeltaSharingScope, + "external_access_enabled": m.ExternalAccessEnabled, "id": m.Id, "new_name": m.NewName, "owner": m.Owner, @@ -30838,6 +30861,7 @@ func (m UpdateMetastore_SdkV2) Type(ctx context.Context) attr.Type { "delta_sharing_organization_name": types.StringType, "delta_sharing_recipient_token_lifetime_in_seconds": types.Int64Type, "delta_sharing_scope": types.StringType, + "external_access_enabled": types.BoolType, "id": types.StringType, "new_name": types.StringType, "owner": types.StringType, diff --git a/internal/service/catalog_tf/model.go b/internal/service/catalog_tf/model.go index 68b9561727..2d59e98cfb 100755 --- a/internal/service/catalog_tf/model.go +++ b/internal/service/catalog_tf/model.go @@ -4382,6 +4382,9 @@ func (m *CreateAccessRequestResponse) SetRequestDestinations(ctx context.Context } type CreateAccountsMetastore struct { + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled types.Bool `tfsdk:"external_access_enabled"` // The user-specified name of the metastore. Name types.String `tfsdk:"name"` // Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). @@ -4397,6 +4400,7 @@ func (to *CreateAccountsMetastore) SyncFieldsDuringRead(ctx context.Context, fro } func (m CreateAccountsMetastore) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["external_access_enabled"] = attrs["external_access_enabled"].SetOptional() attrs["name"] = attrs["name"].SetRequired() attrs["region"] = attrs["region"].SetOptional() attrs["storage_root"] = attrs["storage_root"].SetOptional() @@ -4422,9 +4426,10 @@ func (m CreateAccountsMetastore) ToObjectValue(ctx context.Context) basetypes.Ob return types.ObjectValueMust( m.Type(ctx).(basetypes.ObjectType).AttrTypes, map[string]attr.Value{ - "name": m.Name, - "region": m.Region, - "storage_root": m.StorageRoot, + "external_access_enabled": m.ExternalAccessEnabled, + "name": m.Name, + "region": m.Region, + "storage_root": m.StorageRoot, }) } @@ -4432,9 +4437,10 @@ func (m CreateAccountsMetastore) ToObjectValue(ctx context.Context) basetypes.Ob func (m CreateAccountsMetastore) Type(ctx context.Context) attr.Type { return types.ObjectType{ AttrTypes: map[string]attr.Type{ - "name": types.StringType, - "region": types.StringType, - "storage_root": types.StringType, + "external_access_enabled": types.BoolType, + "name": types.StringType, + "region": types.StringType, + "storage_root": types.StringType, }, } } @@ -6113,6 +6119,9 @@ func (m *CreateFunctionRequest) SetFunctionInfo(ctx context.Context, v CreateFun } type CreateMetastore struct { + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled types.Bool `tfsdk:"external_access_enabled"` // The user-specified name of the metastore. Name types.String `tfsdk:"name"` // Cloud region which the metastore serves (e.g., `us-west-2`, `westus`). @@ -6128,6 +6137,7 @@ func (to *CreateMetastore) SyncFieldsDuringRead(ctx context.Context, from Create } func (m CreateMetastore) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["external_access_enabled"] = attrs["external_access_enabled"].SetOptional() attrs["name"] = attrs["name"].SetRequired() attrs["region"] = attrs["region"].SetOptional() attrs["storage_root"] = attrs["storage_root"].SetOptional() @@ -6153,9 +6163,10 @@ func (m CreateMetastore) ToObjectValue(ctx context.Context) basetypes.ObjectValu return types.ObjectValueMust( m.Type(ctx).(basetypes.ObjectType).AttrTypes, map[string]attr.Value{ - "name": m.Name, - "region": m.Region, - "storage_root": m.StorageRoot, + "external_access_enabled": m.ExternalAccessEnabled, + "name": m.Name, + "region": m.Region, + "storage_root": m.StorageRoot, }) } @@ -6163,9 +6174,10 @@ func (m CreateMetastore) ToObjectValue(ctx context.Context) basetypes.ObjectValu func (m CreateMetastore) Type(ctx context.Context) attr.Type { return types.ObjectType{ AttrTypes: map[string]attr.Type{ - "name": types.StringType, - "region": types.StringType, - "storage_root": types.StringType, + "external_access_enabled": types.BoolType, + "name": types.StringType, + "region": types.StringType, + "storage_root": types.StringType, }, } } @@ -28493,6 +28505,9 @@ type UpdateAccountsMetastore struct { DeltaSharingRecipientTokenLifetimeInSeconds types.Int64 `tfsdk:"delta_sharing_recipient_token_lifetime_in_seconds"` // The scope of Delta Sharing enabled for the metastore. DeltaSharingScope types.String `tfsdk:"delta_sharing_scope"` + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled types.Bool `tfsdk:"external_access_enabled"` // The owner of the metastore. Owner types.String `tfsdk:"owner"` // Privilege model version of the metastore, of the form `major.minor` @@ -28512,6 +28527,7 @@ func (m UpdateAccountsMetastore) ApplySchemaCustomizations(attrs map[string]tfsc attrs["delta_sharing_organization_name"] = attrs["delta_sharing_organization_name"].SetOptional() attrs["delta_sharing_recipient_token_lifetime_in_seconds"] = attrs["delta_sharing_recipient_token_lifetime_in_seconds"].SetOptional() attrs["delta_sharing_scope"] = attrs["delta_sharing_scope"].SetOptional() + attrs["external_access_enabled"] = attrs["external_access_enabled"].SetOptional() attrs["owner"] = attrs["owner"].SetOptional() attrs["privilege_model_version"] = attrs["privilege_model_version"].SetOptional() attrs["storage_root_credential_id"] = attrs["storage_root_credential_id"].SetOptional() @@ -28540,6 +28556,7 @@ func (m UpdateAccountsMetastore) ToObjectValue(ctx context.Context) basetypes.Ob "delta_sharing_organization_name": m.DeltaSharingOrganizationName, "delta_sharing_recipient_token_lifetime_in_seconds": m.DeltaSharingRecipientTokenLifetimeInSeconds, "delta_sharing_scope": m.DeltaSharingScope, + "external_access_enabled": m.ExternalAccessEnabled, "owner": m.Owner, "privilege_model_version": m.PrivilegeModelVersion, "storage_root_credential_id": m.StorageRootCredentialId, @@ -28553,6 +28570,7 @@ func (m UpdateAccountsMetastore) Type(ctx context.Context) attr.Type { "delta_sharing_organization_name": types.StringType, "delta_sharing_recipient_token_lifetime_in_seconds": types.Int64Type, "delta_sharing_scope": types.StringType, + "external_access_enabled": types.BoolType, "owner": types.StringType, "privilege_model_version": types.StringType, "storage_root_credential_id": types.StringType, @@ -30125,6 +30143,9 @@ type UpdateMetastore struct { DeltaSharingRecipientTokenLifetimeInSeconds types.Int64 `tfsdk:"delta_sharing_recipient_token_lifetime_in_seconds"` // The scope of Delta Sharing enabled for the metastore. DeltaSharingScope types.String `tfsdk:"delta_sharing_scope"` + // Whether to allow non-DBR clients to directly access entities under the + // metastore. + ExternalAccessEnabled types.Bool `tfsdk:"external_access_enabled"` // Unique ID of the metastore. Id types.String `tfsdk:"-"` // New name for the metastore. @@ -30148,6 +30169,7 @@ func (m UpdateMetastore) ApplySchemaCustomizations(attrs map[string]tfschema.Att attrs["delta_sharing_organization_name"] = attrs["delta_sharing_organization_name"].SetOptional() attrs["delta_sharing_recipient_token_lifetime_in_seconds"] = attrs["delta_sharing_recipient_token_lifetime_in_seconds"].SetOptional() attrs["delta_sharing_scope"] = attrs["delta_sharing_scope"].SetOptional() + attrs["external_access_enabled"] = attrs["external_access_enabled"].SetOptional() attrs["new_name"] = attrs["new_name"].SetOptional() attrs["owner"] = attrs["owner"].SetOptional() attrs["privilege_model_version"] = attrs["privilege_model_version"].SetOptional() @@ -30178,6 +30200,7 @@ func (m UpdateMetastore) ToObjectValue(ctx context.Context) basetypes.ObjectValu "delta_sharing_organization_name": m.DeltaSharingOrganizationName, "delta_sharing_recipient_token_lifetime_in_seconds": m.DeltaSharingRecipientTokenLifetimeInSeconds, "delta_sharing_scope": m.DeltaSharingScope, + "external_access_enabled": m.ExternalAccessEnabled, "id": m.Id, "new_name": m.NewName, "owner": m.Owner, @@ -30193,6 +30216,7 @@ func (m UpdateMetastore) Type(ctx context.Context) attr.Type { "delta_sharing_organization_name": types.StringType, "delta_sharing_recipient_token_lifetime_in_seconds": types.Int64Type, "delta_sharing_scope": types.StringType, + "external_access_enabled": types.BoolType, "id": types.StringType, "new_name": types.StringType, "owner": types.StringType, diff --git a/internal/service/ml_tf/legacy_model.go b/internal/service/ml_tf/legacy_model.go index 567d44b05e..4707a96847 100755 --- a/internal/service/ml_tf/legacy_model.go +++ b/internal/service/ml_tf/legacy_model.go @@ -14725,6 +14725,8 @@ type OnlineStore_SdkV2 struct { ReadReplicaCount types.Int64 `tfsdk:"read_replica_count"` // The current state of the online store. State types.String `tfsdk:"state"` + // The usage policy applied to the online store to track billing. + UsagePolicyId types.String `tfsdk:"usage_policy_id"` } func (to *OnlineStore_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from OnlineStore_SdkV2) { @@ -14740,6 +14742,7 @@ func (m OnlineStore_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.A attrs["name"] = attrs["name"].SetRequired() attrs["read_replica_count"] = attrs["read_replica_count"].SetOptional() attrs["state"] = attrs["state"].SetComputed() + attrs["usage_policy_id"] = attrs["usage_policy_id"].SetOptional() return attrs } @@ -14768,6 +14771,7 @@ func (m OnlineStore_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectVa "name": m.Name, "read_replica_count": m.ReadReplicaCount, "state": m.State, + "usage_policy_id": m.UsagePolicyId, }) } @@ -14781,6 +14785,7 @@ func (m OnlineStore_SdkV2) Type(ctx context.Context) attr.Type { "name": types.StringType, "read_replica_count": types.Int64Type, "state": types.StringType, + "usage_policy_id": types.StringType, }, } } diff --git a/internal/service/ml_tf/model.go b/internal/service/ml_tf/model.go index d4b3f3b82f..423c88f9b7 100755 --- a/internal/service/ml_tf/model.go +++ b/internal/service/ml_tf/model.go @@ -14561,6 +14561,8 @@ type OnlineStore struct { ReadReplicaCount types.Int64 `tfsdk:"read_replica_count"` // The current state of the online store. State types.String `tfsdk:"state"` + // The usage policy applied to the online store to track billing. + UsagePolicyId types.String `tfsdk:"usage_policy_id"` } func (to *OnlineStore) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from OnlineStore) { @@ -14576,6 +14578,7 @@ func (m OnlineStore) ApplySchemaCustomizations(attrs map[string]tfschema.Attribu attrs["name"] = attrs["name"].SetRequired() attrs["read_replica_count"] = attrs["read_replica_count"].SetOptional() attrs["state"] = attrs["state"].SetComputed() + attrs["usage_policy_id"] = attrs["usage_policy_id"].SetOptional() return attrs } @@ -14604,6 +14607,7 @@ func (m OnlineStore) ToObjectValue(ctx context.Context) basetypes.ObjectValue { "name": m.Name, "read_replica_count": m.ReadReplicaCount, "state": m.State, + "usage_policy_id": m.UsagePolicyId, }) } @@ -14617,6 +14621,7 @@ func (m OnlineStore) Type(ctx context.Context) attr.Type { "name": types.StringType, "read_replica_count": types.Int64Type, "state": types.StringType, + "usage_policy_id": types.StringType, }, } } diff --git a/internal/service/postgres_tf/legacy_model.go b/internal/service/postgres_tf/legacy_model.go new file mode 100755 index 0000000000..ed6ec88929 --- /dev/null +++ b/internal/service/postgres_tf/legacy_model.go @@ -0,0 +1,3015 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. +/* +These generated types are for terraform plugin framework to interact with the terraform state conveniently. + +These types follow the same structure as the types in go-sdk. +The only difference is that the primitive types are no longer using the go-native types, but with tfsdk types. +Plus the json tags get converted into tfsdk tags. +We use go-native types for lists and maps intentionally for the ease for converting these types into the go-sdk types. +*/ + +package postgres_tf + +import ( + "context" + "reflect" + + pluginfwcommon "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/common" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + + "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes" + "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/float64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +type Branch_SdkV2 struct { + // A timestamp indicating when the branch was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + // The branch's state, indicating if it is initializing, ready for use, or + // archived. + CurrentState types.String `tfsdk:"current_state"` + // Whether the branch is the project's default branch. This field is only + // returned on create/update responses. See effective_default for the value + // that is actually applied to the branch. + Default types.Bool `tfsdk:"default"` + // Whether the branch is the project's default branch. + EffectiveDefault types.Bool `tfsdk:"effective_default"` + // Whether the branch is protected. + EffectiveIsProtected types.Bool `tfsdk:"effective_is_protected"` + // The name of the source branch from which this branch was created. Format: + // projects/{project_id}/branches/{branch_id} + EffectiveSourceBranch types.String `tfsdk:"effective_source_branch"` + // The Log Sequence Number (LSN) on the source branch from which this branch + // was created. + EffectiveSourceBranchLsn types.String `tfsdk:"effective_source_branch_lsn"` + // The point in time on the source branch from which this branch was + // created. + EffectiveSourceBranchTime timetypes.RFC3339 `tfsdk:"effective_source_branch_time"` + // Whether the branch is protected. + IsProtected types.Bool `tfsdk:"is_protected"` + // The logical size of the branch. + LogicalSizeBytes types.Int64 `tfsdk:"logical_size_bytes"` + // The resource name of the branch. Format: + // projects/{project_id}/branches/{branch_id} + Name types.String `tfsdk:"name"` + // The project containing this branch. Format: projects/{project_id} + Parent types.String `tfsdk:"parent"` + // The pending state of the branch, if a state transition is in progress. + PendingState types.String `tfsdk:"pending_state"` + // The name of the source branch from which this branch was created. Format: + // projects/{project_id}/branches/{branch_id} + SourceBranch types.String `tfsdk:"source_branch"` + // The Log Sequence Number (LSN) on the source branch from which this branch + // was created. + SourceBranchLsn types.String `tfsdk:"source_branch_lsn"` + // The point in time on the source branch from which this branch was + // created. + SourceBranchTime timetypes.RFC3339 `tfsdk:"source_branch_time"` + // A timestamp indicating when the `current_state` began. + StateChangeTime timetypes.RFC3339 `tfsdk:"state_change_time"` + // System generated unique ID for the branch. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the branch was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +func (to *Branch_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Branch_SdkV2) { + if !from.Default.IsUnknown() && !from.Default.IsNull() { + // Default is an input only field and not returned by the service, so we keep the value from the prior state. + to.Default = from.Default + } + if !from.IsProtected.IsUnknown() && !from.IsProtected.IsNull() { + // IsProtected is an input only field and not returned by the service, so we keep the value from the prior state. + to.IsProtected = from.IsProtected + } + if !from.SourceBranch.IsUnknown() && !from.SourceBranch.IsNull() { + // SourceBranch is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranch = from.SourceBranch + } + if !from.SourceBranchLsn.IsUnknown() && !from.SourceBranchLsn.IsNull() { + // SourceBranchLsn is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchLsn = from.SourceBranchLsn + } + if !from.SourceBranchTime.IsUnknown() && !from.SourceBranchTime.IsNull() { + // SourceBranchTime is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchTime = from.SourceBranchTime + } +} + +func (to *Branch_SdkV2) SyncFieldsDuringRead(ctx context.Context, from Branch_SdkV2) { + if !from.Default.IsUnknown() && !from.Default.IsNull() { + // Default is an input only field and not returned by the service, so we keep the value from the prior state. + to.Default = from.Default + } + if !from.IsProtected.IsUnknown() && !from.IsProtected.IsNull() { + // IsProtected is an input only field and not returned by the service, so we keep the value from the prior state. + to.IsProtected = from.IsProtected + } + if !from.SourceBranch.IsUnknown() && !from.SourceBranch.IsNull() { + // SourceBranch is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranch = from.SourceBranch + } + if !from.SourceBranchLsn.IsUnknown() && !from.SourceBranchLsn.IsNull() { + // SourceBranchLsn is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchLsn = from.SourceBranchLsn + } + if !from.SourceBranchTime.IsUnknown() && !from.SourceBranchTime.IsNull() { + // SourceBranchTime is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchTime = from.SourceBranchTime + } +} + +func (m Branch_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["current_state"] = attrs["current_state"].SetComputed() + attrs["default"] = attrs["default"].SetOptional() + attrs["default"] = attrs["default"].SetComputed() + attrs["default"] = attrs["default"].(tfschema.BoolAttributeBuilder).AddPlanModifier(boolplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["effective_default"] = attrs["effective_default"].SetComputed() + attrs["effective_is_protected"] = attrs["effective_is_protected"].SetComputed() + attrs["effective_source_branch"] = attrs["effective_source_branch"].SetComputed() + attrs["effective_source_branch_lsn"] = attrs["effective_source_branch_lsn"].SetComputed() + attrs["effective_source_branch_time"] = attrs["effective_source_branch_time"].SetComputed() + attrs["is_protected"] = attrs["is_protected"].SetOptional() + attrs["is_protected"] = attrs["is_protected"].SetComputed() + attrs["is_protected"] = attrs["is_protected"].(tfschema.BoolAttributeBuilder).AddPlanModifier(boolplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["logical_size_bytes"] = attrs["logical_size_bytes"].SetComputed() + attrs["name"] = attrs["name"].SetOptional() + attrs["parent"] = attrs["parent"].SetComputed() + attrs["pending_state"] = attrs["pending_state"].SetComputed() + attrs["source_branch"] = attrs["source_branch"].SetOptional() + attrs["source_branch"] = attrs["source_branch"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["source_branch"] = attrs["source_branch"].SetComputed() + attrs["source_branch"] = attrs["source_branch"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].SetOptional() + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].SetComputed() + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["source_branch_time"] = attrs["source_branch_time"].SetOptional() + attrs["source_branch_time"] = attrs["source_branch_time"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["source_branch_time"] = attrs["source_branch_time"].SetComputed() + attrs["source_branch_time"] = attrs["source_branch_time"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["state_change_time"] = attrs["state_change_time"].SetComputed() + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in Branch. +// 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 (m Branch_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, Branch_SdkV2 +// only implements ToObjectValue() and Type(). +func (m Branch_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "create_time": m.CreateTime, + "current_state": m.CurrentState, + "default": m.Default, + "effective_default": m.EffectiveDefault, + "effective_is_protected": m.EffectiveIsProtected, + "effective_source_branch": m.EffectiveSourceBranch, + "effective_source_branch_lsn": m.EffectiveSourceBranchLsn, + "effective_source_branch_time": m.EffectiveSourceBranchTime, + "is_protected": m.IsProtected, + "logical_size_bytes": m.LogicalSizeBytes, + "name": m.Name, + "parent": m.Parent, + "pending_state": m.PendingState, + "source_branch": m.SourceBranch, + "source_branch_lsn": m.SourceBranchLsn, + "source_branch_time": m.SourceBranchTime, + "state_change_time": m.StateChangeTime, + "uid": m.Uid, + "update_time": m.UpdateTime, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m Branch_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "create_time": timetypes.RFC3339{}.Type(ctx), + "current_state": types.StringType, + "default": types.BoolType, + "effective_default": types.BoolType, + "effective_is_protected": types.BoolType, + "effective_source_branch": types.StringType, + "effective_source_branch_lsn": types.StringType, + "effective_source_branch_time": timetypes.RFC3339{}.Type(ctx), + "is_protected": types.BoolType, + "logical_size_bytes": types.Int64Type, + "name": types.StringType, + "parent": types.StringType, + "pending_state": types.StringType, + "source_branch": types.StringType, + "source_branch_lsn": types.StringType, + "source_branch_time": timetypes.RFC3339{}.Type(ctx), + "state_change_time": timetypes.RFC3339{}.Type(ctx), + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +type BranchOperationMetadata_SdkV2 struct { +} + +func (to *BranchOperationMetadata_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from BranchOperationMetadata_SdkV2) { +} + +func (to *BranchOperationMetadata_SdkV2) SyncFieldsDuringRead(ctx context.Context, from BranchOperationMetadata_SdkV2) { +} + +func (m BranchOperationMetadata_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in BranchOperationMetadata. +// 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 (m BranchOperationMetadata_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, BranchOperationMetadata_SdkV2 +// only implements ToObjectValue() and Type(). +func (m BranchOperationMetadata_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{}) +} + +// Type implements basetypes.ObjectValuable. +func (m BranchOperationMetadata_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{}, + } +} + +type CreateBranchRequest_SdkV2 struct { + // The Branch to create. + Branch types.List `tfsdk:"branch"` + // The ID to use for the Branch, which will become the final component of + // the branch's resource name. + // + // This value should be 4-63 characters, and valid characters are + // /[a-z][0-9]-/. + BranchId types.String `tfsdk:"-"` + // The Project where this Branch will be created. Format: + // projects/{project_id} + Parent types.String `tfsdk:"-"` +} + +func (to *CreateBranchRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from CreateBranchRequest_SdkV2) { + if !from.Branch.IsNull() && !from.Branch.IsUnknown() { + if toBranch, ok := to.GetBranch(ctx); ok { + if fromBranch, ok := from.GetBranch(ctx); ok { + // Recursively sync the fields of Branch + toBranch.SyncFieldsDuringCreateOrUpdate(ctx, fromBranch) + to.SetBranch(ctx, toBranch) + } + } + } +} + +func (to *CreateBranchRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from CreateBranchRequest_SdkV2) { + if !from.Branch.IsNull() && !from.Branch.IsUnknown() { + if toBranch, ok := to.GetBranch(ctx); ok { + if fromBranch, ok := from.GetBranch(ctx); ok { + toBranch.SyncFieldsDuringRead(ctx, fromBranch) + to.SetBranch(ctx, toBranch) + } + } + } +} + +func (m CreateBranchRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["branch"] = attrs["branch"].SetRequired() + attrs["branch"] = attrs["branch"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["parent"] = attrs["parent"].SetRequired() + attrs["branch_id"] = attrs["branch_id"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in CreateBranchRequest. +// 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 (m CreateBranchRequest_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "branch": reflect.TypeOf(Branch_SdkV2{}), + } +} + +// 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, CreateBranchRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m CreateBranchRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "branch": m.Branch, + "branch_id": m.BranchId, + "parent": m.Parent, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m CreateBranchRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "branch": basetypes.ListType{ + ElemType: Branch_SdkV2{}.Type(ctx), + }, + "branch_id": types.StringType, + "parent": types.StringType, + }, + } +} + +// GetBranch returns the value of the Branch field in CreateBranchRequest_SdkV2 as +// a Branch_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *CreateBranchRequest_SdkV2) GetBranch(ctx context.Context) (Branch_SdkV2, bool) { + var e Branch_SdkV2 + if m.Branch.IsNull() || m.Branch.IsUnknown() { + return e, false + } + var v []Branch_SdkV2 + d := m.Branch.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetBranch sets the value of the Branch field in CreateBranchRequest_SdkV2. +func (m *CreateBranchRequest_SdkV2) SetBranch(ctx context.Context, v Branch_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["branch"] + m.Branch = types.ListValueMust(t, vs) +} + +type CreateEndpointRequest_SdkV2 struct { + // The Endpoint to create. + Endpoint types.List `tfsdk:"endpoint"` + // The ID to use for the Endpoint, which will become the final component of + // the endpoint's resource name. + // + // This value should be 4-63 characters, and valid characters are + // /[a-z][0-9]-/. + EndpointId types.String `tfsdk:"-"` + // The Branch where this Endpoint will be created. Format: + // projects/{project_id}/branches/{branch_id} + Parent types.String `tfsdk:"-"` +} + +func (to *CreateEndpointRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from CreateEndpointRequest_SdkV2) { + if !from.Endpoint.IsNull() && !from.Endpoint.IsUnknown() { + if toEndpoint, ok := to.GetEndpoint(ctx); ok { + if fromEndpoint, ok := from.GetEndpoint(ctx); ok { + // Recursively sync the fields of Endpoint + toEndpoint.SyncFieldsDuringCreateOrUpdate(ctx, fromEndpoint) + to.SetEndpoint(ctx, toEndpoint) + } + } + } +} + +func (to *CreateEndpointRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from CreateEndpointRequest_SdkV2) { + if !from.Endpoint.IsNull() && !from.Endpoint.IsUnknown() { + if toEndpoint, ok := to.GetEndpoint(ctx); ok { + if fromEndpoint, ok := from.GetEndpoint(ctx); ok { + toEndpoint.SyncFieldsDuringRead(ctx, fromEndpoint) + to.SetEndpoint(ctx, toEndpoint) + } + } + } +} + +func (m CreateEndpointRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["endpoint"] = attrs["endpoint"].SetRequired() + attrs["endpoint"] = attrs["endpoint"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["parent"] = attrs["parent"].SetRequired() + attrs["endpoint_id"] = attrs["endpoint_id"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in CreateEndpointRequest. +// 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 (m CreateEndpointRequest_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "endpoint": reflect.TypeOf(Endpoint_SdkV2{}), + } +} + +// 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, CreateEndpointRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m CreateEndpointRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "endpoint": m.Endpoint, + "endpoint_id": m.EndpointId, + "parent": m.Parent, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m CreateEndpointRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "endpoint": basetypes.ListType{ + ElemType: Endpoint_SdkV2{}.Type(ctx), + }, + "endpoint_id": types.StringType, + "parent": types.StringType, + }, + } +} + +// GetEndpoint returns the value of the Endpoint field in CreateEndpointRequest_SdkV2 as +// a Endpoint_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *CreateEndpointRequest_SdkV2) GetEndpoint(ctx context.Context) (Endpoint_SdkV2, bool) { + var e Endpoint_SdkV2 + if m.Endpoint.IsNull() || m.Endpoint.IsUnknown() { + return e, false + } + var v []Endpoint_SdkV2 + d := m.Endpoint.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetEndpoint sets the value of the Endpoint field in CreateEndpointRequest_SdkV2. +func (m *CreateEndpointRequest_SdkV2) SetEndpoint(ctx context.Context, v Endpoint_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["endpoint"] + m.Endpoint = types.ListValueMust(t, vs) +} + +type CreateProjectRequest_SdkV2 struct { + // The Project to create. + Project types.List `tfsdk:"project"` + // The ID to use for the Project, which will become the final component of + // the project's resource name. + // + // This value should be 4-63 characters, and valid characters are + // /[a-z][0-9]-/. + ProjectId types.String `tfsdk:"-"` +} + +func (to *CreateProjectRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from CreateProjectRequest_SdkV2) { + if !from.Project.IsNull() && !from.Project.IsUnknown() { + if toProject, ok := to.GetProject(ctx); ok { + if fromProject, ok := from.GetProject(ctx); ok { + // Recursively sync the fields of Project + toProject.SyncFieldsDuringCreateOrUpdate(ctx, fromProject) + to.SetProject(ctx, toProject) + } + } + } +} + +func (to *CreateProjectRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from CreateProjectRequest_SdkV2) { + if !from.Project.IsNull() && !from.Project.IsUnknown() { + if toProject, ok := to.GetProject(ctx); ok { + if fromProject, ok := from.GetProject(ctx); ok { + toProject.SyncFieldsDuringRead(ctx, fromProject) + to.SetProject(ctx, toProject) + } + } + } +} + +func (m CreateProjectRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["project"] = attrs["project"].SetRequired() + attrs["project"] = attrs["project"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["project_id"] = attrs["project_id"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in CreateProjectRequest. +// 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 (m CreateProjectRequest_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "project": reflect.TypeOf(Project_SdkV2{}), + } +} + +// 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, CreateProjectRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m CreateProjectRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "project": m.Project, + "project_id": m.ProjectId, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m CreateProjectRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "project": basetypes.ListType{ + ElemType: Project_SdkV2{}.Type(ctx), + }, + "project_id": types.StringType, + }, + } +} + +// GetProject returns the value of the Project field in CreateProjectRequest_SdkV2 as +// a Project_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *CreateProjectRequest_SdkV2) GetProject(ctx context.Context) (Project_SdkV2, bool) { + var e Project_SdkV2 + if m.Project.IsNull() || m.Project.IsUnknown() { + return e, false + } + var v []Project_SdkV2 + d := m.Project.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetProject sets the value of the Project field in CreateProjectRequest_SdkV2. +func (m *CreateProjectRequest_SdkV2) SetProject(ctx context.Context, v Project_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["project"] + m.Project = types.ListValueMust(t, vs) +} + +// Databricks Error that is returned by all Databricks APIs. +type DatabricksServiceExceptionWithDetailsProto_SdkV2 struct { + // @pbjson-skip + Details types.List `tfsdk:"details"` + + ErrorCode types.String `tfsdk:"error_code"` + + Message types.String `tfsdk:"message"` + + StackTrace types.String `tfsdk:"stack_trace"` +} + +func (to *DatabricksServiceExceptionWithDetailsProto_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from DatabricksServiceExceptionWithDetailsProto_SdkV2) { + if !from.Details.IsNull() && !from.Details.IsUnknown() && to.Details.IsNull() && len(from.Details.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Details, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Details = from.Details + } +} + +func (to *DatabricksServiceExceptionWithDetailsProto_SdkV2) SyncFieldsDuringRead(ctx context.Context, from DatabricksServiceExceptionWithDetailsProto_SdkV2) { + if !from.Details.IsNull() && !from.Details.IsUnknown() && to.Details.IsNull() && len(from.Details.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Details, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Details = from.Details + } +} + +func (m DatabricksServiceExceptionWithDetailsProto_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["details"] = attrs["details"].SetOptional() + attrs["error_code"] = attrs["error_code"].SetOptional() + attrs["message"] = attrs["message"].SetOptional() + attrs["stack_trace"] = attrs["stack_trace"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in DatabricksServiceExceptionWithDetailsProto. +// 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 (m DatabricksServiceExceptionWithDetailsProto_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "details": reflect.TypeOf(types.Object{}), + } +} + +// 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, DatabricksServiceExceptionWithDetailsProto_SdkV2 +// only implements ToObjectValue() and Type(). +func (m DatabricksServiceExceptionWithDetailsProto_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "details": m.Details, + "error_code": m.ErrorCode, + "message": m.Message, + "stack_trace": m.StackTrace, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m DatabricksServiceExceptionWithDetailsProto_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "details": basetypes.ListType{ + ElemType: types.ObjectType{}, + }, + "error_code": types.StringType, + "message": types.StringType, + "stack_trace": types.StringType, + }, + } +} + +// GetDetails returns the value of the Details field in DatabricksServiceExceptionWithDetailsProto_SdkV2 as +// a slice of types.Object values. +// If the field is unknown or null, the boolean return value is false. +func (m *DatabricksServiceExceptionWithDetailsProto_SdkV2) GetDetails(ctx context.Context) ([]types.Object, bool) { + if m.Details.IsNull() || m.Details.IsUnknown() { + return nil, false + } + var v []types.Object + d := m.Details.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetDetails sets the value of the Details field in DatabricksServiceExceptionWithDetailsProto_SdkV2. +func (m *DatabricksServiceExceptionWithDetailsProto_SdkV2) SetDetails(ctx context.Context, v []types.Object) { + vs := make([]attr.Value, 0, len(v)) + for _, e := range v { + vs = append(vs, e) + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["details"] + t = t.(attr.TypeWithElementType).ElementType() + m.Details = types.ListValueMust(t, vs) +} + +type DeleteBranchRequest_SdkV2 struct { + // The name of the Branch to delete. Format: + // projects/{project_id}/branches/{branch_id} + Name types.String `tfsdk:"-"` +} + +func (to *DeleteBranchRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from DeleteBranchRequest_SdkV2) { +} + +func (to *DeleteBranchRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from DeleteBranchRequest_SdkV2) { +} + +func (m DeleteBranchRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in DeleteBranchRequest. +// 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 (m DeleteBranchRequest_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, DeleteBranchRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m DeleteBranchRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m DeleteBranchRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type DeleteEndpointRequest_SdkV2 struct { + // The name of the Endpoint to delete. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name types.String `tfsdk:"-"` +} + +func (to *DeleteEndpointRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from DeleteEndpointRequest_SdkV2) { +} + +func (to *DeleteEndpointRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from DeleteEndpointRequest_SdkV2) { +} + +func (m DeleteEndpointRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in DeleteEndpointRequest. +// 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 (m DeleteEndpointRequest_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, DeleteEndpointRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m DeleteEndpointRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m DeleteEndpointRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type DeleteProjectRequest_SdkV2 struct { + // The name of the Project to delete. Format: projects/{project_id} + Name types.String `tfsdk:"-"` +} + +func (to *DeleteProjectRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from DeleteProjectRequest_SdkV2) { +} + +func (to *DeleteProjectRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from DeleteProjectRequest_SdkV2) { +} + +func (m DeleteProjectRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in DeleteProjectRequest. +// 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 (m DeleteProjectRequest_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, DeleteProjectRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m DeleteProjectRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m DeleteProjectRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type Endpoint_SdkV2 struct { + // The maximum number of Compute Units. + AutoscalingLimitMaxCu types.Float64 `tfsdk:"autoscaling_limit_max_cu"` + // The minimum number of Compute Units. + AutoscalingLimitMinCu types.Float64 `tfsdk:"autoscaling_limit_min_cu"` + // A timestamp indicating when the compute endpoint was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + + CurrentState types.String `tfsdk:"current_state"` + // Whether to restrict connections to the compute endpoint. Enabling this + // option schedules a suspend compute operation. A disabled compute endpoint + // cannot be enabled by a connection or console action. + Disabled types.Bool `tfsdk:"disabled"` + // The maximum number of Compute Units. + EffectiveAutoscalingLimitMaxCu types.Float64 `tfsdk:"effective_autoscaling_limit_max_cu"` + // The minimum number of Compute Units. + EffectiveAutoscalingLimitMinCu types.Float64 `tfsdk:"effective_autoscaling_limit_min_cu"` + // Whether to restrict connections to the compute endpoint. Enabling this + // option schedules a suspend compute operation. A disabled compute endpoint + // cannot be enabled by a connection or console action. + EffectiveDisabled types.Bool `tfsdk:"effective_disabled"` + + EffectivePoolerMode types.String `tfsdk:"effective_pooler_mode"` + + EffectiveSettings types.List `tfsdk:"effective_settings"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + EffectiveSuspendTimeoutDuration timetypes.GoDuration `tfsdk:"effective_suspend_timeout_duration"` + // The endpoint type. There could be only one READ_WRITE endpoint per + // branch. + EndpointType types.String `tfsdk:"endpoint_type"` + // The hostname of the compute endpoint. This is the hostname specified when + // connecting to a database. + Host types.String `tfsdk:"host"` + // A timestamp indicating when the compute endpoint was last active. + LastActiveTime timetypes.RFC3339 `tfsdk:"last_active_time"` + // The resource name of the endpoint. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name types.String `tfsdk:"name"` + // The branch containing this endpoint. Format: + // projects/{project_id}/branches/{branch_id} + Parent types.String `tfsdk:"parent"` + + PendingState types.String `tfsdk:"pending_state"` + + PoolerMode types.String `tfsdk:"pooler_mode"` + + Settings types.List `tfsdk:"settings"` + // A timestamp indicating when the compute endpoint was last started. + StartTime timetypes.RFC3339 `tfsdk:"start_time"` + // A timestamp indicating when the compute endpoint was last suspended. + SuspendTime timetypes.RFC3339 `tfsdk:"suspend_time"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + SuspendTimeoutDuration timetypes.GoDuration `tfsdk:"suspend_timeout_duration"` + // System generated unique ID for the endpoint. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the compute endpoint was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +func (to *Endpoint_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Endpoint_SdkV2) { + if !from.AutoscalingLimitMaxCu.IsUnknown() && !from.AutoscalingLimitMaxCu.IsNull() { + // AutoscalingLimitMaxCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMaxCu = from.AutoscalingLimitMaxCu + } + if !from.AutoscalingLimitMinCu.IsUnknown() && !from.AutoscalingLimitMinCu.IsNull() { + // AutoscalingLimitMinCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMinCu = from.AutoscalingLimitMinCu + } + if !from.Disabled.IsUnknown() && !from.Disabled.IsNull() { + // Disabled is an input only field and not returned by the service, so we keep the value from the prior state. + to.Disabled = from.Disabled + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + // Recursively sync the fields of EffectiveSettings + toEffectiveSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + if !from.PoolerMode.IsUnknown() && !from.PoolerMode.IsNull() { + // PoolerMode is an input only field and not returned by the service, so we keep the value from the prior state. + to.PoolerMode = from.PoolerMode + } + if !from.Settings.IsUnknown() && !from.Settings.IsNull() { + // Settings is an input only field and not returned by the service, so we keep the value from the prior state. + to.Settings = from.Settings + } + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + // Recursively sync the fields of Settings + toSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } + if !from.SuspendTimeoutDuration.IsUnknown() && !from.SuspendTimeoutDuration.IsNull() { + // SuspendTimeoutDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.SuspendTimeoutDuration = from.SuspendTimeoutDuration + } +} + +func (to *Endpoint_SdkV2) SyncFieldsDuringRead(ctx context.Context, from Endpoint_SdkV2) { + if !from.AutoscalingLimitMaxCu.IsUnknown() && !from.AutoscalingLimitMaxCu.IsNull() { + // AutoscalingLimitMaxCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMaxCu = from.AutoscalingLimitMaxCu + } + if !from.AutoscalingLimitMinCu.IsUnknown() && !from.AutoscalingLimitMinCu.IsNull() { + // AutoscalingLimitMinCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMinCu = from.AutoscalingLimitMinCu + } + if !from.Disabled.IsUnknown() && !from.Disabled.IsNull() { + // Disabled is an input only field and not returned by the service, so we keep the value from the prior state. + to.Disabled = from.Disabled + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + toEffectiveSettings.SyncFieldsDuringRead(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + if !from.PoolerMode.IsUnknown() && !from.PoolerMode.IsNull() { + // PoolerMode is an input only field and not returned by the service, so we keep the value from the prior state. + to.PoolerMode = from.PoolerMode + } + if !from.Settings.IsUnknown() && !from.Settings.IsNull() { + // Settings is an input only field and not returned by the service, so we keep the value from the prior state. + to.Settings = from.Settings + } + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + toSettings.SyncFieldsDuringRead(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } + if !from.SuspendTimeoutDuration.IsUnknown() && !from.SuspendTimeoutDuration.IsNull() { + // SuspendTimeoutDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.SuspendTimeoutDuration = from.SuspendTimeoutDuration + } +} + +func (m Endpoint_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].SetOptional() + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].SetComputed() + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].(tfschema.Float64AttributeBuilder).AddPlanModifier(float64planmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].SetOptional() + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].SetComputed() + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].(tfschema.Float64AttributeBuilder).AddPlanModifier(float64planmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["current_state"] = attrs["current_state"].SetComputed() + attrs["disabled"] = attrs["disabled"].SetOptional() + attrs["disabled"] = attrs["disabled"].SetComputed() + attrs["disabled"] = attrs["disabled"].(tfschema.BoolAttributeBuilder).AddPlanModifier(boolplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["effective_autoscaling_limit_max_cu"] = attrs["effective_autoscaling_limit_max_cu"].SetComputed() + attrs["effective_autoscaling_limit_min_cu"] = attrs["effective_autoscaling_limit_min_cu"].SetComputed() + attrs["effective_disabled"] = attrs["effective_disabled"].SetComputed() + attrs["effective_pooler_mode"] = attrs["effective_pooler_mode"].SetComputed() + attrs["effective_settings"] = attrs["effective_settings"].SetComputed() + attrs["effective_settings"] = attrs["effective_settings"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["effective_suspend_timeout_duration"] = attrs["effective_suspend_timeout_duration"].SetComputed() + attrs["endpoint_type"] = attrs["endpoint_type"].SetRequired() + attrs["endpoint_type"] = attrs["endpoint_type"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["host"] = attrs["host"].SetComputed() + attrs["last_active_time"] = attrs["last_active_time"].SetComputed() + attrs["name"] = attrs["name"].SetOptional() + attrs["parent"] = attrs["parent"].SetComputed() + attrs["pending_state"] = attrs["pending_state"].SetComputed() + attrs["pooler_mode"] = attrs["pooler_mode"].SetOptional() + attrs["pooler_mode"] = attrs["pooler_mode"].SetComputed() + attrs["pooler_mode"] = attrs["pooler_mode"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["settings"] = attrs["settings"].SetOptional() + attrs["settings"] = attrs["settings"].SetComputed() + attrs["settings"] = attrs["settings"].(tfschema.ListNestedAttributeBuilder).AddPlanModifier(listplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["settings"] = attrs["settings"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["start_time"] = attrs["start_time"].SetComputed() + attrs["suspend_time"] = attrs["suspend_time"].SetComputed() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].SetOptional() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].SetComputed() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in Endpoint. +// 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 (m Endpoint_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "effective_settings": reflect.TypeOf(EndpointSettings_SdkV2{}), + "settings": reflect.TypeOf(EndpointSettings_SdkV2{}), + } +} + +// 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, Endpoint_SdkV2 +// only implements ToObjectValue() and Type(). +func (m Endpoint_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "autoscaling_limit_max_cu": m.AutoscalingLimitMaxCu, + "autoscaling_limit_min_cu": m.AutoscalingLimitMinCu, + "create_time": m.CreateTime, + "current_state": m.CurrentState, + "disabled": m.Disabled, + "effective_autoscaling_limit_max_cu": m.EffectiveAutoscalingLimitMaxCu, + "effective_autoscaling_limit_min_cu": m.EffectiveAutoscalingLimitMinCu, + "effective_disabled": m.EffectiveDisabled, + "effective_pooler_mode": m.EffectivePoolerMode, + "effective_settings": m.EffectiveSettings, + "effective_suspend_timeout_duration": m.EffectiveSuspendTimeoutDuration, + "endpoint_type": m.EndpointType, + "host": m.Host, + "last_active_time": m.LastActiveTime, + "name": m.Name, + "parent": m.Parent, + "pending_state": m.PendingState, + "pooler_mode": m.PoolerMode, + "settings": m.Settings, + "start_time": m.StartTime, + "suspend_time": m.SuspendTime, + "suspend_timeout_duration": m.SuspendTimeoutDuration, + "uid": m.Uid, + "update_time": m.UpdateTime, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m Endpoint_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "autoscaling_limit_max_cu": types.Float64Type, + "autoscaling_limit_min_cu": types.Float64Type, + "create_time": timetypes.RFC3339{}.Type(ctx), + "current_state": types.StringType, + "disabled": types.BoolType, + "effective_autoscaling_limit_max_cu": types.Float64Type, + "effective_autoscaling_limit_min_cu": types.Float64Type, + "effective_disabled": types.BoolType, + "effective_pooler_mode": types.StringType, + "effective_settings": basetypes.ListType{ + ElemType: EndpointSettings_SdkV2{}.Type(ctx), + }, + "effective_suspend_timeout_duration": timetypes.GoDuration{}.Type(ctx), + "endpoint_type": types.StringType, + "host": types.StringType, + "last_active_time": timetypes.RFC3339{}.Type(ctx), + "name": types.StringType, + "parent": types.StringType, + "pending_state": types.StringType, + "pooler_mode": types.StringType, + "settings": basetypes.ListType{ + ElemType: EndpointSettings_SdkV2{}.Type(ctx), + }, + "start_time": timetypes.RFC3339{}.Type(ctx), + "suspend_time": timetypes.RFC3339{}.Type(ctx), + "suspend_timeout_duration": timetypes.GoDuration{}.Type(ctx), + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +// GetEffectiveSettings returns the value of the EffectiveSettings field in Endpoint_SdkV2 as +// a EndpointSettings_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *Endpoint_SdkV2) GetEffectiveSettings(ctx context.Context) (EndpointSettings_SdkV2, bool) { + var e EndpointSettings_SdkV2 + if m.EffectiveSettings.IsNull() || m.EffectiveSettings.IsUnknown() { + return e, false + } + var v []EndpointSettings_SdkV2 + d := m.EffectiveSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetEffectiveSettings sets the value of the EffectiveSettings field in Endpoint_SdkV2. +func (m *Endpoint_SdkV2) SetEffectiveSettings(ctx context.Context, v EndpointSettings_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["effective_settings"] + m.EffectiveSettings = types.ListValueMust(t, vs) +} + +// GetSettings returns the value of the Settings field in Endpoint_SdkV2 as +// a EndpointSettings_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *Endpoint_SdkV2) GetSettings(ctx context.Context) (EndpointSettings_SdkV2, bool) { + var e EndpointSettings_SdkV2 + if m.Settings.IsNull() || m.Settings.IsUnknown() { + return e, false + } + var v []EndpointSettings_SdkV2 + d := m.Settings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetSettings sets the value of the Settings field in Endpoint_SdkV2. +func (m *Endpoint_SdkV2) SetSettings(ctx context.Context, v EndpointSettings_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["settings"] + m.Settings = types.ListValueMust(t, vs) +} + +type EndpointOperationMetadata_SdkV2 struct { +} + +func (to *EndpointOperationMetadata_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from EndpointOperationMetadata_SdkV2) { +} + +func (to *EndpointOperationMetadata_SdkV2) SyncFieldsDuringRead(ctx context.Context, from EndpointOperationMetadata_SdkV2) { +} + +func (m EndpointOperationMetadata_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in EndpointOperationMetadata. +// 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 (m EndpointOperationMetadata_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, EndpointOperationMetadata_SdkV2 +// only implements ToObjectValue() and Type(). +func (m EndpointOperationMetadata_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{}) +} + +// Type implements basetypes.ObjectValuable. +func (m EndpointOperationMetadata_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{}, + } +} + +// A collection of settings for a compute endpoint. +type EndpointSettings_SdkV2 struct { + // A raw representation of Postgres settings. + PgSettings types.Map `tfsdk:"pg_settings"` + // A raw representation of PgBouncer settings. + PgbouncerSettings types.Map `tfsdk:"pgbouncer_settings"` +} + +func (to *EndpointSettings_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from EndpointSettings_SdkV2) { +} + +func (to *EndpointSettings_SdkV2) SyncFieldsDuringRead(ctx context.Context, from EndpointSettings_SdkV2) { +} + +func (m EndpointSettings_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["pg_settings"] = attrs["pg_settings"].SetOptional() + attrs["pgbouncer_settings"] = attrs["pgbouncer_settings"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in EndpointSettings. +// 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 (m EndpointSettings_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "pg_settings": reflect.TypeOf(types.String{}), + "pgbouncer_settings": reflect.TypeOf(types.String{}), + } +} + +// 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, EndpointSettings_SdkV2 +// only implements ToObjectValue() and Type(). +func (m EndpointSettings_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "pg_settings": m.PgSettings, + "pgbouncer_settings": m.PgbouncerSettings, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m EndpointSettings_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "pg_settings": basetypes.MapType{ + ElemType: types.StringType, + }, + "pgbouncer_settings": basetypes.MapType{ + ElemType: types.StringType, + }, + }, + } +} + +// GetPgSettings returns the value of the PgSettings field in EndpointSettings_SdkV2 as +// a map of string to types.String values. +// If the field is unknown or null, the boolean return value is false. +func (m *EndpointSettings_SdkV2) GetPgSettings(ctx context.Context) (map[string]types.String, bool) { + if m.PgSettings.IsNull() || m.PgSettings.IsUnknown() { + return nil, false + } + var v map[string]types.String + d := m.PgSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetPgSettings sets the value of the PgSettings field in EndpointSettings_SdkV2. +func (m *EndpointSettings_SdkV2) SetPgSettings(ctx context.Context, v map[string]types.String) { + vs := make(map[string]attr.Value, len(v)) + for k, e := range v { + vs[k] = e + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["pg_settings"] + t = t.(attr.TypeWithElementType).ElementType() + m.PgSettings = types.MapValueMust(t, vs) +} + +// GetPgbouncerSettings returns the value of the PgbouncerSettings field in EndpointSettings_SdkV2 as +// a map of string to types.String values. +// If the field is unknown or null, the boolean return value is false. +func (m *EndpointSettings_SdkV2) GetPgbouncerSettings(ctx context.Context) (map[string]types.String, bool) { + if m.PgbouncerSettings.IsNull() || m.PgbouncerSettings.IsUnknown() { + return nil, false + } + var v map[string]types.String + d := m.PgbouncerSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetPgbouncerSettings sets the value of the PgbouncerSettings field in EndpointSettings_SdkV2. +func (m *EndpointSettings_SdkV2) SetPgbouncerSettings(ctx context.Context, v map[string]types.String) { + vs := make(map[string]attr.Value, len(v)) + for k, e := range v { + vs[k] = e + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["pgbouncer_settings"] + t = t.(attr.TypeWithElementType).ElementType() + m.PgbouncerSettings = types.MapValueMust(t, vs) +} + +type GetBranchRequest_SdkV2 struct { + // The name of the Branch to retrieve. Format: + // projects/{project_id}/branches/{branch_id} + Name types.String `tfsdk:"-"` +} + +func (to *GetBranchRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from GetBranchRequest_SdkV2) { +} + +func (to *GetBranchRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from GetBranchRequest_SdkV2) { +} + +func (m GetBranchRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in GetBranchRequest. +// 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 (m GetBranchRequest_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, GetBranchRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m GetBranchRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m GetBranchRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type GetEndpointRequest_SdkV2 struct { + // The name of the Endpoint to retrieve. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name types.String `tfsdk:"-"` +} + +func (to *GetEndpointRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from GetEndpointRequest_SdkV2) { +} + +func (to *GetEndpointRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from GetEndpointRequest_SdkV2) { +} + +func (m GetEndpointRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in GetEndpointRequest. +// 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 (m GetEndpointRequest_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, GetEndpointRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m GetEndpointRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m GetEndpointRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type GetOperationRequest_SdkV2 struct { + // The name of the operation resource. + Name types.String `tfsdk:"-"` +} + +func (to *GetOperationRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from GetOperationRequest_SdkV2) { +} + +func (to *GetOperationRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from GetOperationRequest_SdkV2) { +} + +func (m GetOperationRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in GetOperationRequest. +// 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 (m GetOperationRequest_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, GetOperationRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m GetOperationRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m GetOperationRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type GetProjectRequest_SdkV2 struct { + // The name of the Project to retrieve. Format: projects/{project_id} + Name types.String `tfsdk:"-"` +} + +func (to *GetProjectRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from GetProjectRequest_SdkV2) { +} + +func (to *GetProjectRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from GetProjectRequest_SdkV2) { +} + +func (m GetProjectRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in GetProjectRequest. +// 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 (m GetProjectRequest_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, GetProjectRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m GetProjectRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m GetProjectRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type ListBranchesRequest_SdkV2 struct { + // Upper bound for items returned. + PageSize types.Int64 `tfsdk:"-"` + // Pagination token to go to the next page of Branches. Requests first page + // if absent. + PageToken types.String `tfsdk:"-"` + // The Project that owns this collection of branches. Format: + // projects/{project_id} + Parent types.String `tfsdk:"-"` +} + +func (to *ListBranchesRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListBranchesRequest_SdkV2) { +} + +func (to *ListBranchesRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from ListBranchesRequest_SdkV2) { +} + +func (m ListBranchesRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["parent"] = attrs["parent"].SetRequired() + attrs["page_token"] = attrs["page_token"].SetOptional() + attrs["page_size"] = attrs["page_size"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListBranchesRequest. +// 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 (m ListBranchesRequest_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, ListBranchesRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m ListBranchesRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "page_size": m.PageSize, + "page_token": m.PageToken, + "parent": m.Parent, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListBranchesRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "page_size": types.Int64Type, + "page_token": types.StringType, + "parent": types.StringType, + }, + } +} + +type ListBranchesResponse_SdkV2 struct { + // List of branches. + Branches types.List `tfsdk:"branches"` + // Pagination token to request the next page of branches. + NextPageToken types.String `tfsdk:"next_page_token"` +} + +func (to *ListBranchesResponse_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListBranchesResponse_SdkV2) { + if !from.Branches.IsNull() && !from.Branches.IsUnknown() && to.Branches.IsNull() && len(from.Branches.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Branches, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Branches = from.Branches + } +} + +func (to *ListBranchesResponse_SdkV2) SyncFieldsDuringRead(ctx context.Context, from ListBranchesResponse_SdkV2) { + if !from.Branches.IsNull() && !from.Branches.IsUnknown() && to.Branches.IsNull() && len(from.Branches.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Branches, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Branches = from.Branches + } +} + +func (m ListBranchesResponse_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["branches"] = attrs["branches"].SetOptional() + attrs["next_page_token"] = attrs["next_page_token"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListBranchesResponse. +// 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 (m ListBranchesResponse_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "branches": reflect.TypeOf(Branch_SdkV2{}), + } +} + +// 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, ListBranchesResponse_SdkV2 +// only implements ToObjectValue() and Type(). +func (m ListBranchesResponse_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "branches": m.Branches, + "next_page_token": m.NextPageToken, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListBranchesResponse_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "branches": basetypes.ListType{ + ElemType: Branch_SdkV2{}.Type(ctx), + }, + "next_page_token": types.StringType, + }, + } +} + +// GetBranches returns the value of the Branches field in ListBranchesResponse_SdkV2 as +// a slice of Branch_SdkV2 values. +// If the field is unknown or null, the boolean return value is false. +func (m *ListBranchesResponse_SdkV2) GetBranches(ctx context.Context) ([]Branch_SdkV2, bool) { + if m.Branches.IsNull() || m.Branches.IsUnknown() { + return nil, false + } + var v []Branch_SdkV2 + d := m.Branches.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetBranches sets the value of the Branches field in ListBranchesResponse_SdkV2. +func (m *ListBranchesResponse_SdkV2) SetBranches(ctx context.Context, v []Branch_SdkV2) { + vs := make([]attr.Value, 0, len(v)) + for _, e := range v { + vs = append(vs, e.ToObjectValue(ctx)) + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["branches"] + t = t.(attr.TypeWithElementType).ElementType() + m.Branches = types.ListValueMust(t, vs) +} + +type ListEndpointsRequest_SdkV2 struct { + // Upper bound for items returned. + PageSize types.Int64 `tfsdk:"-"` + // Pagination token to go to the next page of Endpoints. Requests first page + // if absent. + PageToken types.String `tfsdk:"-"` + // The Branch that owns this collection of endpoints. Format: + // projects/{project_id}/branches/{branch_id} + Parent types.String `tfsdk:"-"` +} + +func (to *ListEndpointsRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListEndpointsRequest_SdkV2) { +} + +func (to *ListEndpointsRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from ListEndpointsRequest_SdkV2) { +} + +func (m ListEndpointsRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["parent"] = attrs["parent"].SetRequired() + attrs["page_token"] = attrs["page_token"].SetOptional() + attrs["page_size"] = attrs["page_size"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListEndpointsRequest. +// 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 (m ListEndpointsRequest_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, ListEndpointsRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m ListEndpointsRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "page_size": m.PageSize, + "page_token": m.PageToken, + "parent": m.Parent, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListEndpointsRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "page_size": types.Int64Type, + "page_token": types.StringType, + "parent": types.StringType, + }, + } +} + +type ListEndpointsResponse_SdkV2 struct { + // List of endpoints. + Endpoints types.List `tfsdk:"endpoints"` + // Pagination token to request the next page of endpoints. + NextPageToken types.String `tfsdk:"next_page_token"` +} + +func (to *ListEndpointsResponse_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListEndpointsResponse_SdkV2) { + if !from.Endpoints.IsNull() && !from.Endpoints.IsUnknown() && to.Endpoints.IsNull() && len(from.Endpoints.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Endpoints, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Endpoints = from.Endpoints + } +} + +func (to *ListEndpointsResponse_SdkV2) SyncFieldsDuringRead(ctx context.Context, from ListEndpointsResponse_SdkV2) { + if !from.Endpoints.IsNull() && !from.Endpoints.IsUnknown() && to.Endpoints.IsNull() && len(from.Endpoints.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Endpoints, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Endpoints = from.Endpoints + } +} + +func (m ListEndpointsResponse_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["endpoints"] = attrs["endpoints"].SetOptional() + attrs["next_page_token"] = attrs["next_page_token"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListEndpointsResponse. +// 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 (m ListEndpointsResponse_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "endpoints": reflect.TypeOf(Endpoint_SdkV2{}), + } +} + +// 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, ListEndpointsResponse_SdkV2 +// only implements ToObjectValue() and Type(). +func (m ListEndpointsResponse_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "endpoints": m.Endpoints, + "next_page_token": m.NextPageToken, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListEndpointsResponse_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "endpoints": basetypes.ListType{ + ElemType: Endpoint_SdkV2{}.Type(ctx), + }, + "next_page_token": types.StringType, + }, + } +} + +// GetEndpoints returns the value of the Endpoints field in ListEndpointsResponse_SdkV2 as +// a slice of Endpoint_SdkV2 values. +// If the field is unknown or null, the boolean return value is false. +func (m *ListEndpointsResponse_SdkV2) GetEndpoints(ctx context.Context) ([]Endpoint_SdkV2, bool) { + if m.Endpoints.IsNull() || m.Endpoints.IsUnknown() { + return nil, false + } + var v []Endpoint_SdkV2 + d := m.Endpoints.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetEndpoints sets the value of the Endpoints field in ListEndpointsResponse_SdkV2. +func (m *ListEndpointsResponse_SdkV2) SetEndpoints(ctx context.Context, v []Endpoint_SdkV2) { + vs := make([]attr.Value, 0, len(v)) + for _, e := range v { + vs = append(vs, e.ToObjectValue(ctx)) + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["endpoints"] + t = t.(attr.TypeWithElementType).ElementType() + m.Endpoints = types.ListValueMust(t, vs) +} + +type ListProjectsRequest_SdkV2 struct { + // Upper bound for items returned. + PageSize types.Int64 `tfsdk:"-"` + // Pagination token to go to the next page of Projects. Requests first page + // if absent. + PageToken types.String `tfsdk:"-"` +} + +func (to *ListProjectsRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListProjectsRequest_SdkV2) { +} + +func (to *ListProjectsRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from ListProjectsRequest_SdkV2) { +} + +func (m ListProjectsRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["page_token"] = attrs["page_token"].SetOptional() + attrs["page_size"] = attrs["page_size"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListProjectsRequest. +// 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 (m ListProjectsRequest_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, ListProjectsRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m ListProjectsRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "page_size": m.PageSize, + "page_token": m.PageToken, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListProjectsRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "page_size": types.Int64Type, + "page_token": types.StringType, + }, + } +} + +type ListProjectsResponse_SdkV2 struct { + // Pagination token to request the next page of projects. + NextPageToken types.String `tfsdk:"next_page_token"` + // List of projects. + Projects types.List `tfsdk:"projects"` +} + +func (to *ListProjectsResponse_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListProjectsResponse_SdkV2) { + if !from.Projects.IsNull() && !from.Projects.IsUnknown() && to.Projects.IsNull() && len(from.Projects.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Projects, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Projects = from.Projects + } +} + +func (to *ListProjectsResponse_SdkV2) SyncFieldsDuringRead(ctx context.Context, from ListProjectsResponse_SdkV2) { + if !from.Projects.IsNull() && !from.Projects.IsUnknown() && to.Projects.IsNull() && len(from.Projects.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Projects, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Projects = from.Projects + } +} + +func (m ListProjectsResponse_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["next_page_token"] = attrs["next_page_token"].SetOptional() + attrs["projects"] = attrs["projects"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListProjectsResponse. +// 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 (m ListProjectsResponse_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "projects": reflect.TypeOf(Project_SdkV2{}), + } +} + +// 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, ListProjectsResponse_SdkV2 +// only implements ToObjectValue() and Type(). +func (m ListProjectsResponse_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "next_page_token": m.NextPageToken, + "projects": m.Projects, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListProjectsResponse_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "next_page_token": types.StringType, + "projects": basetypes.ListType{ + ElemType: Project_SdkV2{}.Type(ctx), + }, + }, + } +} + +// GetProjects returns the value of the Projects field in ListProjectsResponse_SdkV2 as +// a slice of Project_SdkV2 values. +// If the field is unknown or null, the boolean return value is false. +func (m *ListProjectsResponse_SdkV2) GetProjects(ctx context.Context) ([]Project_SdkV2, bool) { + if m.Projects.IsNull() || m.Projects.IsUnknown() { + return nil, false + } + var v []Project_SdkV2 + d := m.Projects.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetProjects sets the value of the Projects field in ListProjectsResponse_SdkV2. +func (m *ListProjectsResponse_SdkV2) SetProjects(ctx context.Context, v []Project_SdkV2) { + vs := make([]attr.Value, 0, len(v)) + for _, e := range v { + vs = append(vs, e.ToObjectValue(ctx)) + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["projects"] + t = t.(attr.TypeWithElementType).ElementType() + m.Projects = types.ListValueMust(t, vs) +} + +// This resource represents a long-running operation that is the result of a +// network API call. +type Operation_SdkV2 struct { + // If the value is `false`, it means the operation is still in progress. If + // `true`, the operation is completed, and either `error` or `response` is + // available. + Done types.Bool `tfsdk:"done"` + // The error result of the operation in case of failure or cancellation. + Error types.List `tfsdk:"error"` + // Service-specific metadata associated with the operation. It typically + // contains progress information and common metadata such as create time. + // Some services might not provide such metadata. + Metadata types.Object `tfsdk:"metadata"` + // The server-assigned name, which is only unique within the same service + // that originally returns it. If you use the default HTTP mapping, the + // `name` should be a resource name ending with `operations/{unique_id}`. + Name types.String `tfsdk:"name"` + // The normal, successful response of the operation. + Response types.Object `tfsdk:"response"` +} + +func (to *Operation_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Operation_SdkV2) { + if !from.Error.IsNull() && !from.Error.IsUnknown() { + if toError, ok := to.GetError(ctx); ok { + if fromError, ok := from.GetError(ctx); ok { + // Recursively sync the fields of Error + toError.SyncFieldsDuringCreateOrUpdate(ctx, fromError) + to.SetError(ctx, toError) + } + } + } +} + +func (to *Operation_SdkV2) SyncFieldsDuringRead(ctx context.Context, from Operation_SdkV2) { + if !from.Error.IsNull() && !from.Error.IsUnknown() { + if toError, ok := to.GetError(ctx); ok { + if fromError, ok := from.GetError(ctx); ok { + toError.SyncFieldsDuringRead(ctx, fromError) + to.SetError(ctx, toError) + } + } + } +} + +func (m Operation_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["done"] = attrs["done"].SetOptional() + attrs["error"] = attrs["error"].SetOptional() + attrs["error"] = attrs["error"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["metadata"] = attrs["metadata"].SetOptional() + attrs["name"] = attrs["name"].SetOptional() + attrs["response"] = attrs["response"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in Operation. +// 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 (m Operation_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "error": reflect.TypeOf(DatabricksServiceExceptionWithDetailsProto_SdkV2{}), + } +} + +// 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, Operation_SdkV2 +// only implements ToObjectValue() and Type(). +func (m Operation_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "done": m.Done, + "error": m.Error, + "metadata": m.Metadata, + "name": m.Name, + "response": m.Response, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m Operation_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "done": types.BoolType, + "error": basetypes.ListType{ + ElemType: DatabricksServiceExceptionWithDetailsProto_SdkV2{}.Type(ctx), + }, + "metadata": types.ObjectType{}, + "name": types.StringType, + "response": types.ObjectType{}, + }, + } +} + +// GetError returns the value of the Error field in Operation_SdkV2 as +// a DatabricksServiceExceptionWithDetailsProto_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *Operation_SdkV2) GetError(ctx context.Context) (DatabricksServiceExceptionWithDetailsProto_SdkV2, bool) { + var e DatabricksServiceExceptionWithDetailsProto_SdkV2 + if m.Error.IsNull() || m.Error.IsUnknown() { + return e, false + } + var v []DatabricksServiceExceptionWithDetailsProto_SdkV2 + d := m.Error.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetError sets the value of the Error field in Operation_SdkV2. +func (m *Operation_SdkV2) SetError(ctx context.Context, v DatabricksServiceExceptionWithDetailsProto_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["error"] + m.Error = types.ListValueMust(t, vs) +} + +type Project_SdkV2 struct { + // The logical size limit for a branch. + BranchLogicalSizeLimitBytes types.Int64 `tfsdk:"branch_logical_size_limit_bytes"` + // The most recent time when any endpoint of this project was active. + ComputeLastActiveTime timetypes.RFC3339 `tfsdk:"compute_last_active_time"` + // A timestamp indicating when the project was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + + DefaultEndpointSettings types.List `tfsdk:"default_endpoint_settings"` + // Human-readable project name. + DisplayName types.String `tfsdk:"display_name"` + + EffectiveDefaultEndpointSettings types.List `tfsdk:"effective_default_endpoint_settings"` + + EffectiveDisplayName types.String `tfsdk:"effective_display_name"` + + EffectiveHistoryRetentionDuration timetypes.GoDuration `tfsdk:"effective_history_retention_duration"` + + EffectivePgVersion types.Int64 `tfsdk:"effective_pg_version"` + + EffectiveSettings types.List `tfsdk:"effective_settings"` + // The number of seconds to retain the shared history for point in time + // recovery for all branches in this project. + HistoryRetentionDuration timetypes.GoDuration `tfsdk:"history_retention_duration"` + // The resource name of the project. Format: projects/{project_id} + Name types.String `tfsdk:"name"` + // The major Postgres version number. + PgVersion types.Int64 `tfsdk:"pg_version"` + + Settings types.List `tfsdk:"settings"` + // The current space occupied by the project in storage. Synthetic storage + // size combines the logical data size and Write-Ahead Log (WAL) size for + // all branches in a project. + SyntheticStorageSizeBytes types.Int64 `tfsdk:"synthetic_storage_size_bytes"` + // System generated unique ID for the project. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the project was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +func (to *Project_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Project_SdkV2) { + if !from.DefaultEndpointSettings.IsUnknown() && !from.DefaultEndpointSettings.IsNull() { + // DefaultEndpointSettings is an input only field and not returned by the service, so we keep the value from the prior state. + to.DefaultEndpointSettings = from.DefaultEndpointSettings + } + if !from.DefaultEndpointSettings.IsNull() && !from.DefaultEndpointSettings.IsUnknown() { + if toDefaultEndpointSettings, ok := to.GetDefaultEndpointSettings(ctx); ok { + if fromDefaultEndpointSettings, ok := from.GetDefaultEndpointSettings(ctx); ok { + // Recursively sync the fields of DefaultEndpointSettings + toDefaultEndpointSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromDefaultEndpointSettings) + to.SetDefaultEndpointSettings(ctx, toDefaultEndpointSettings) + } + } + } + if !from.DisplayName.IsUnknown() && !from.DisplayName.IsNull() { + // DisplayName is an input only field and not returned by the service, so we keep the value from the prior state. + to.DisplayName = from.DisplayName + } + if !from.EffectiveDefaultEndpointSettings.IsNull() && !from.EffectiveDefaultEndpointSettings.IsUnknown() { + if toEffectiveDefaultEndpointSettings, ok := to.GetEffectiveDefaultEndpointSettings(ctx); ok { + if fromEffectiveDefaultEndpointSettings, ok := from.GetEffectiveDefaultEndpointSettings(ctx); ok { + // Recursively sync the fields of EffectiveDefaultEndpointSettings + toEffectiveDefaultEndpointSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromEffectiveDefaultEndpointSettings) + to.SetEffectiveDefaultEndpointSettings(ctx, toEffectiveDefaultEndpointSettings) + } + } + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + // Recursively sync the fields of EffectiveSettings + toEffectiveSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + if !from.HistoryRetentionDuration.IsUnknown() && !from.HistoryRetentionDuration.IsNull() { + // HistoryRetentionDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.HistoryRetentionDuration = from.HistoryRetentionDuration + } + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + // Recursively sync the fields of Settings + toSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } +} + +func (to *Project_SdkV2) SyncFieldsDuringRead(ctx context.Context, from Project_SdkV2) { + if !from.DefaultEndpointSettings.IsUnknown() && !from.DefaultEndpointSettings.IsNull() { + // DefaultEndpointSettings is an input only field and not returned by the service, so we keep the value from the prior state. + to.DefaultEndpointSettings = from.DefaultEndpointSettings + } + if !from.DefaultEndpointSettings.IsNull() && !from.DefaultEndpointSettings.IsUnknown() { + if toDefaultEndpointSettings, ok := to.GetDefaultEndpointSettings(ctx); ok { + if fromDefaultEndpointSettings, ok := from.GetDefaultEndpointSettings(ctx); ok { + toDefaultEndpointSettings.SyncFieldsDuringRead(ctx, fromDefaultEndpointSettings) + to.SetDefaultEndpointSettings(ctx, toDefaultEndpointSettings) + } + } + } + if !from.DisplayName.IsUnknown() && !from.DisplayName.IsNull() { + // DisplayName is an input only field and not returned by the service, so we keep the value from the prior state. + to.DisplayName = from.DisplayName + } + if !from.EffectiveDefaultEndpointSettings.IsNull() && !from.EffectiveDefaultEndpointSettings.IsUnknown() { + if toEffectiveDefaultEndpointSettings, ok := to.GetEffectiveDefaultEndpointSettings(ctx); ok { + if fromEffectiveDefaultEndpointSettings, ok := from.GetEffectiveDefaultEndpointSettings(ctx); ok { + toEffectiveDefaultEndpointSettings.SyncFieldsDuringRead(ctx, fromEffectiveDefaultEndpointSettings) + to.SetEffectiveDefaultEndpointSettings(ctx, toEffectiveDefaultEndpointSettings) + } + } + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + toEffectiveSettings.SyncFieldsDuringRead(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + if !from.HistoryRetentionDuration.IsUnknown() && !from.HistoryRetentionDuration.IsNull() { + // HistoryRetentionDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.HistoryRetentionDuration = from.HistoryRetentionDuration + } + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + toSettings.SyncFieldsDuringRead(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } +} + +func (m Project_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["branch_logical_size_limit_bytes"] = attrs["branch_logical_size_limit_bytes"].SetComputed() + attrs["compute_last_active_time"] = attrs["compute_last_active_time"].SetComputed() + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].SetOptional() + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].SetComputed() + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].(tfschema.ListNestedAttributeBuilder).AddPlanModifier(listplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["display_name"] = attrs["display_name"].SetOptional() + attrs["display_name"] = attrs["display_name"].SetComputed() + attrs["display_name"] = attrs["display_name"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["effective_default_endpoint_settings"] = attrs["effective_default_endpoint_settings"].SetComputed() + attrs["effective_default_endpoint_settings"] = attrs["effective_default_endpoint_settings"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["effective_display_name"] = attrs["effective_display_name"].SetComputed() + attrs["effective_history_retention_duration"] = attrs["effective_history_retention_duration"].SetComputed() + attrs["effective_pg_version"] = attrs["effective_pg_version"].SetComputed() + attrs["effective_settings"] = attrs["effective_settings"].SetComputed() + attrs["effective_settings"] = attrs["effective_settings"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["history_retention_duration"] = attrs["history_retention_duration"].SetOptional() + attrs["history_retention_duration"] = attrs["history_retention_duration"].SetComputed() + attrs["history_retention_duration"] = attrs["history_retention_duration"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["name"] = attrs["name"].SetOptional() + attrs["pg_version"] = attrs["pg_version"].SetOptional() + attrs["pg_version"] = attrs["pg_version"].(tfschema.Int64AttributeBuilder).AddPlanModifier(int64planmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["settings"] = attrs["settings"].SetOptional() + attrs["settings"] = attrs["settings"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["synthetic_storage_size_bytes"] = attrs["synthetic_storage_size_bytes"].SetComputed() + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in Project. +// 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 (m Project_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "default_endpoint_settings": reflect.TypeOf(ProjectDefaultEndpointSettings_SdkV2{}), + "effective_default_endpoint_settings": reflect.TypeOf(ProjectDefaultEndpointSettings_SdkV2{}), + "effective_settings": reflect.TypeOf(ProjectSettings_SdkV2{}), + "settings": reflect.TypeOf(ProjectSettings_SdkV2{}), + } +} + +// 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, Project_SdkV2 +// only implements ToObjectValue() and Type(). +func (m Project_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "branch_logical_size_limit_bytes": m.BranchLogicalSizeLimitBytes, + "compute_last_active_time": m.ComputeLastActiveTime, + "create_time": m.CreateTime, + "default_endpoint_settings": m.DefaultEndpointSettings, + "display_name": m.DisplayName, + "effective_default_endpoint_settings": m.EffectiveDefaultEndpointSettings, + "effective_display_name": m.EffectiveDisplayName, + "effective_history_retention_duration": m.EffectiveHistoryRetentionDuration, + "effective_pg_version": m.EffectivePgVersion, + "effective_settings": m.EffectiveSettings, + "history_retention_duration": m.HistoryRetentionDuration, + "name": m.Name, + "pg_version": m.PgVersion, + "settings": m.Settings, + "synthetic_storage_size_bytes": m.SyntheticStorageSizeBytes, + "uid": m.Uid, + "update_time": m.UpdateTime, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m Project_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "branch_logical_size_limit_bytes": types.Int64Type, + "compute_last_active_time": timetypes.RFC3339{}.Type(ctx), + "create_time": timetypes.RFC3339{}.Type(ctx), + "default_endpoint_settings": basetypes.ListType{ + ElemType: ProjectDefaultEndpointSettings_SdkV2{}.Type(ctx), + }, + "display_name": types.StringType, + "effective_default_endpoint_settings": basetypes.ListType{ + ElemType: ProjectDefaultEndpointSettings_SdkV2{}.Type(ctx), + }, + "effective_display_name": types.StringType, + "effective_history_retention_duration": timetypes.GoDuration{}.Type(ctx), + "effective_pg_version": types.Int64Type, + "effective_settings": basetypes.ListType{ + ElemType: ProjectSettings_SdkV2{}.Type(ctx), + }, + "history_retention_duration": timetypes.GoDuration{}.Type(ctx), + "name": types.StringType, + "pg_version": types.Int64Type, + "settings": basetypes.ListType{ + ElemType: ProjectSettings_SdkV2{}.Type(ctx), + }, + "synthetic_storage_size_bytes": types.Int64Type, + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +// GetDefaultEndpointSettings returns the value of the DefaultEndpointSettings field in Project_SdkV2 as +// a ProjectDefaultEndpointSettings_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project_SdkV2) GetDefaultEndpointSettings(ctx context.Context) (ProjectDefaultEndpointSettings_SdkV2, bool) { + var e ProjectDefaultEndpointSettings_SdkV2 + if m.DefaultEndpointSettings.IsNull() || m.DefaultEndpointSettings.IsUnknown() { + return e, false + } + var v []ProjectDefaultEndpointSettings_SdkV2 + d := m.DefaultEndpointSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetDefaultEndpointSettings sets the value of the DefaultEndpointSettings field in Project_SdkV2. +func (m *Project_SdkV2) SetDefaultEndpointSettings(ctx context.Context, v ProjectDefaultEndpointSettings_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["default_endpoint_settings"] + m.DefaultEndpointSettings = types.ListValueMust(t, vs) +} + +// GetEffectiveDefaultEndpointSettings returns the value of the EffectiveDefaultEndpointSettings field in Project_SdkV2 as +// a ProjectDefaultEndpointSettings_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project_SdkV2) GetEffectiveDefaultEndpointSettings(ctx context.Context) (ProjectDefaultEndpointSettings_SdkV2, bool) { + var e ProjectDefaultEndpointSettings_SdkV2 + if m.EffectiveDefaultEndpointSettings.IsNull() || m.EffectiveDefaultEndpointSettings.IsUnknown() { + return e, false + } + var v []ProjectDefaultEndpointSettings_SdkV2 + d := m.EffectiveDefaultEndpointSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetEffectiveDefaultEndpointSettings sets the value of the EffectiveDefaultEndpointSettings field in Project_SdkV2. +func (m *Project_SdkV2) SetEffectiveDefaultEndpointSettings(ctx context.Context, v ProjectDefaultEndpointSettings_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["effective_default_endpoint_settings"] + m.EffectiveDefaultEndpointSettings = types.ListValueMust(t, vs) +} + +// GetEffectiveSettings returns the value of the EffectiveSettings field in Project_SdkV2 as +// a ProjectSettings_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project_SdkV2) GetEffectiveSettings(ctx context.Context) (ProjectSettings_SdkV2, bool) { + var e ProjectSettings_SdkV2 + if m.EffectiveSettings.IsNull() || m.EffectiveSettings.IsUnknown() { + return e, false + } + var v []ProjectSettings_SdkV2 + d := m.EffectiveSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetEffectiveSettings sets the value of the EffectiveSettings field in Project_SdkV2. +func (m *Project_SdkV2) SetEffectiveSettings(ctx context.Context, v ProjectSettings_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["effective_settings"] + m.EffectiveSettings = types.ListValueMust(t, vs) +} + +// GetSettings returns the value of the Settings field in Project_SdkV2 as +// a ProjectSettings_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project_SdkV2) GetSettings(ctx context.Context) (ProjectSettings_SdkV2, bool) { + var e ProjectSettings_SdkV2 + if m.Settings.IsNull() || m.Settings.IsUnknown() { + return e, false + } + var v []ProjectSettings_SdkV2 + d := m.Settings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetSettings sets the value of the Settings field in Project_SdkV2. +func (m *Project_SdkV2) SetSettings(ctx context.Context, v ProjectSettings_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["settings"] + m.Settings = types.ListValueMust(t, vs) +} + +// A collection of settings for a compute endpoint. +type ProjectDefaultEndpointSettings_SdkV2 struct { + // The maximum number of Compute Units. + AutoscalingLimitMaxCu types.Float64 `tfsdk:"autoscaling_limit_max_cu"` + // The minimum number of Compute Units. + AutoscalingLimitMinCu types.Float64 `tfsdk:"autoscaling_limit_min_cu"` + // A raw representation of Postgres settings. + PgSettings types.Map `tfsdk:"pg_settings"` + // A raw representation of PgBouncer settings. + PgbouncerSettings types.Map `tfsdk:"pgbouncer_settings"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + SuspendTimeoutDuration timetypes.GoDuration `tfsdk:"suspend_timeout_duration"` +} + +func (to *ProjectDefaultEndpointSettings_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ProjectDefaultEndpointSettings_SdkV2) { +} + +func (to *ProjectDefaultEndpointSettings_SdkV2) SyncFieldsDuringRead(ctx context.Context, from ProjectDefaultEndpointSettings_SdkV2) { +} + +func (m ProjectDefaultEndpointSettings_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].SetOptional() + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].SetOptional() + attrs["pg_settings"] = attrs["pg_settings"].SetOptional() + attrs["pgbouncer_settings"] = attrs["pgbouncer_settings"].SetOptional() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ProjectDefaultEndpointSettings. +// 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 (m ProjectDefaultEndpointSettings_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "pg_settings": reflect.TypeOf(types.String{}), + "pgbouncer_settings": reflect.TypeOf(types.String{}), + } +} + +// 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, ProjectDefaultEndpointSettings_SdkV2 +// only implements ToObjectValue() and Type(). +func (m ProjectDefaultEndpointSettings_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "autoscaling_limit_max_cu": m.AutoscalingLimitMaxCu, + "autoscaling_limit_min_cu": m.AutoscalingLimitMinCu, + "pg_settings": m.PgSettings, + "pgbouncer_settings": m.PgbouncerSettings, + "suspend_timeout_duration": m.SuspendTimeoutDuration, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ProjectDefaultEndpointSettings_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "autoscaling_limit_max_cu": types.Float64Type, + "autoscaling_limit_min_cu": types.Float64Type, + "pg_settings": basetypes.MapType{ + ElemType: types.StringType, + }, + "pgbouncer_settings": basetypes.MapType{ + ElemType: types.StringType, + }, + "suspend_timeout_duration": timetypes.GoDuration{}.Type(ctx), + }, + } +} + +// GetPgSettings returns the value of the PgSettings field in ProjectDefaultEndpointSettings_SdkV2 as +// a map of string to types.String values. +// If the field is unknown or null, the boolean return value is false. +func (m *ProjectDefaultEndpointSettings_SdkV2) GetPgSettings(ctx context.Context) (map[string]types.String, bool) { + if m.PgSettings.IsNull() || m.PgSettings.IsUnknown() { + return nil, false + } + var v map[string]types.String + d := m.PgSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetPgSettings sets the value of the PgSettings field in ProjectDefaultEndpointSettings_SdkV2. +func (m *ProjectDefaultEndpointSettings_SdkV2) SetPgSettings(ctx context.Context, v map[string]types.String) { + vs := make(map[string]attr.Value, len(v)) + for k, e := range v { + vs[k] = e + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["pg_settings"] + t = t.(attr.TypeWithElementType).ElementType() + m.PgSettings = types.MapValueMust(t, vs) +} + +// GetPgbouncerSettings returns the value of the PgbouncerSettings field in ProjectDefaultEndpointSettings_SdkV2 as +// a map of string to types.String values. +// If the field is unknown or null, the boolean return value is false. +func (m *ProjectDefaultEndpointSettings_SdkV2) GetPgbouncerSettings(ctx context.Context) (map[string]types.String, bool) { + if m.PgbouncerSettings.IsNull() || m.PgbouncerSettings.IsUnknown() { + return nil, false + } + var v map[string]types.String + d := m.PgbouncerSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetPgbouncerSettings sets the value of the PgbouncerSettings field in ProjectDefaultEndpointSettings_SdkV2. +func (m *ProjectDefaultEndpointSettings_SdkV2) SetPgbouncerSettings(ctx context.Context, v map[string]types.String) { + vs := make(map[string]attr.Value, len(v)) + for k, e := range v { + vs[k] = e + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["pgbouncer_settings"] + t = t.(attr.TypeWithElementType).ElementType() + m.PgbouncerSettings = types.MapValueMust(t, vs) +} + +type ProjectOperationMetadata_SdkV2 struct { +} + +func (to *ProjectOperationMetadata_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ProjectOperationMetadata_SdkV2) { +} + +func (to *ProjectOperationMetadata_SdkV2) SyncFieldsDuringRead(ctx context.Context, from ProjectOperationMetadata_SdkV2) { +} + +func (m ProjectOperationMetadata_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ProjectOperationMetadata. +// 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 (m ProjectOperationMetadata_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, ProjectOperationMetadata_SdkV2 +// only implements ToObjectValue() and Type(). +func (m ProjectOperationMetadata_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{}) +} + +// Type implements basetypes.ObjectValuable. +func (m ProjectOperationMetadata_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{}, + } +} + +type ProjectSettings_SdkV2 struct { + // Sets wal_level=logical for all compute endpoints in this project. All + // active endpoints will be suspended. Once enabled, logical replication + // cannot be disabled. + EnableLogicalReplication types.Bool `tfsdk:"enable_logical_replication"` +} + +func (to *ProjectSettings_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ProjectSettings_SdkV2) { +} + +func (to *ProjectSettings_SdkV2) SyncFieldsDuringRead(ctx context.Context, from ProjectSettings_SdkV2) { +} + +func (m ProjectSettings_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["enable_logical_replication"] = attrs["enable_logical_replication"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ProjectSettings. +// 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 (m ProjectSettings_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, ProjectSettings_SdkV2 +// only implements ToObjectValue() and Type(). +func (m ProjectSettings_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "enable_logical_replication": m.EnableLogicalReplication, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ProjectSettings_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "enable_logical_replication": types.BoolType, + }, + } +} + +type UpdateBranchRequest_SdkV2 struct { + // The Branch to update. + // + // The branch's `name` field is used to identify the branch to update. + // Format: projects/{project_id}/branches/{branch_id} + Branch types.List `tfsdk:"branch"` + // The resource name of the branch. Format: + // projects/{project_id}/branches/{branch_id} + Name types.String `tfsdk:"-"` + // The list of fields to update. If unspecified, all fields will be updated + // when possible. + UpdateMask types.String `tfsdk:"-"` +} + +func (to *UpdateBranchRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from UpdateBranchRequest_SdkV2) { + if !from.Branch.IsNull() && !from.Branch.IsUnknown() { + if toBranch, ok := to.GetBranch(ctx); ok { + if fromBranch, ok := from.GetBranch(ctx); ok { + // Recursively sync the fields of Branch + toBranch.SyncFieldsDuringCreateOrUpdate(ctx, fromBranch) + to.SetBranch(ctx, toBranch) + } + } + } +} + +func (to *UpdateBranchRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from UpdateBranchRequest_SdkV2) { + if !from.Branch.IsNull() && !from.Branch.IsUnknown() { + if toBranch, ok := to.GetBranch(ctx); ok { + if fromBranch, ok := from.GetBranch(ctx); ok { + toBranch.SyncFieldsDuringRead(ctx, fromBranch) + to.SetBranch(ctx, toBranch) + } + } + } +} + +func (m UpdateBranchRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["branch"] = attrs["branch"].SetRequired() + attrs["branch"] = attrs["branch"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["name"] = attrs["name"].SetRequired() + attrs["update_mask"] = attrs["update_mask"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in UpdateBranchRequest. +// 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 (m UpdateBranchRequest_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "branch": reflect.TypeOf(Branch_SdkV2{}), + } +} + +// 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, UpdateBranchRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m UpdateBranchRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "branch": m.Branch, + "name": m.Name, + "update_mask": m.UpdateMask, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m UpdateBranchRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "branch": basetypes.ListType{ + ElemType: Branch_SdkV2{}.Type(ctx), + }, + "name": types.StringType, + "update_mask": types.StringType, + }, + } +} + +// GetBranch returns the value of the Branch field in UpdateBranchRequest_SdkV2 as +// a Branch_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *UpdateBranchRequest_SdkV2) GetBranch(ctx context.Context) (Branch_SdkV2, bool) { + var e Branch_SdkV2 + if m.Branch.IsNull() || m.Branch.IsUnknown() { + return e, false + } + var v []Branch_SdkV2 + d := m.Branch.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetBranch sets the value of the Branch field in UpdateBranchRequest_SdkV2. +func (m *UpdateBranchRequest_SdkV2) SetBranch(ctx context.Context, v Branch_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["branch"] + m.Branch = types.ListValueMust(t, vs) +} + +type UpdateEndpointRequest_SdkV2 struct { + // The Endpoint to update. + // + // The endpoint's `name` field is used to identify the endpoint to update. + // Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Endpoint types.List `tfsdk:"endpoint"` + // The resource name of the endpoint. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name types.String `tfsdk:"-"` + // The list of fields to update. If unspecified, all fields will be updated + // when possible. + UpdateMask types.String `tfsdk:"-"` +} + +func (to *UpdateEndpointRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from UpdateEndpointRequest_SdkV2) { + if !from.Endpoint.IsNull() && !from.Endpoint.IsUnknown() { + if toEndpoint, ok := to.GetEndpoint(ctx); ok { + if fromEndpoint, ok := from.GetEndpoint(ctx); ok { + // Recursively sync the fields of Endpoint + toEndpoint.SyncFieldsDuringCreateOrUpdate(ctx, fromEndpoint) + to.SetEndpoint(ctx, toEndpoint) + } + } + } +} + +func (to *UpdateEndpointRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from UpdateEndpointRequest_SdkV2) { + if !from.Endpoint.IsNull() && !from.Endpoint.IsUnknown() { + if toEndpoint, ok := to.GetEndpoint(ctx); ok { + if fromEndpoint, ok := from.GetEndpoint(ctx); ok { + toEndpoint.SyncFieldsDuringRead(ctx, fromEndpoint) + to.SetEndpoint(ctx, toEndpoint) + } + } + } +} + +func (m UpdateEndpointRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["endpoint"] = attrs["endpoint"].SetRequired() + attrs["endpoint"] = attrs["endpoint"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["name"] = attrs["name"].SetRequired() + attrs["update_mask"] = attrs["update_mask"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in UpdateEndpointRequest. +// 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 (m UpdateEndpointRequest_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "endpoint": reflect.TypeOf(Endpoint_SdkV2{}), + } +} + +// 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, UpdateEndpointRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m UpdateEndpointRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "endpoint": m.Endpoint, + "name": m.Name, + "update_mask": m.UpdateMask, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m UpdateEndpointRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "endpoint": basetypes.ListType{ + ElemType: Endpoint_SdkV2{}.Type(ctx), + }, + "name": types.StringType, + "update_mask": types.StringType, + }, + } +} + +// GetEndpoint returns the value of the Endpoint field in UpdateEndpointRequest_SdkV2 as +// a Endpoint_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *UpdateEndpointRequest_SdkV2) GetEndpoint(ctx context.Context) (Endpoint_SdkV2, bool) { + var e Endpoint_SdkV2 + if m.Endpoint.IsNull() || m.Endpoint.IsUnknown() { + return e, false + } + var v []Endpoint_SdkV2 + d := m.Endpoint.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetEndpoint sets the value of the Endpoint field in UpdateEndpointRequest_SdkV2. +func (m *UpdateEndpointRequest_SdkV2) SetEndpoint(ctx context.Context, v Endpoint_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["endpoint"] + m.Endpoint = types.ListValueMust(t, vs) +} + +type UpdateProjectRequest_SdkV2 struct { + // The resource name of the project. Format: projects/{project_id} + Name types.String `tfsdk:"-"` + // The Project to update. + // + // The project's `name` field is used to identify the project to update. + // Format: projects/{project_id} + Project types.List `tfsdk:"project"` + // The list of fields to update. If unspecified, all fields will be updated + // when possible. + UpdateMask types.String `tfsdk:"-"` +} + +func (to *UpdateProjectRequest_SdkV2) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from UpdateProjectRequest_SdkV2) { + if !from.Project.IsNull() && !from.Project.IsUnknown() { + if toProject, ok := to.GetProject(ctx); ok { + if fromProject, ok := from.GetProject(ctx); ok { + // Recursively sync the fields of Project + toProject.SyncFieldsDuringCreateOrUpdate(ctx, fromProject) + to.SetProject(ctx, toProject) + } + } + } +} + +func (to *UpdateProjectRequest_SdkV2) SyncFieldsDuringRead(ctx context.Context, from UpdateProjectRequest_SdkV2) { + if !from.Project.IsNull() && !from.Project.IsUnknown() { + if toProject, ok := to.GetProject(ctx); ok { + if fromProject, ok := from.GetProject(ctx); ok { + toProject.SyncFieldsDuringRead(ctx, fromProject) + to.SetProject(ctx, toProject) + } + } + } +} + +func (m UpdateProjectRequest_SdkV2) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["project"] = attrs["project"].SetRequired() + attrs["project"] = attrs["project"].(tfschema.ListNestedAttributeBuilder).AddValidator(listvalidator.SizeAtMost(1)).(tfschema.AttributeBuilder) + attrs["name"] = attrs["name"].SetRequired() + attrs["update_mask"] = attrs["update_mask"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in UpdateProjectRequest. +// 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 (m UpdateProjectRequest_SdkV2) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "project": reflect.TypeOf(Project_SdkV2{}), + } +} + +// 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, UpdateProjectRequest_SdkV2 +// only implements ToObjectValue() and Type(). +func (m UpdateProjectRequest_SdkV2) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + "project": m.Project, + "update_mask": m.UpdateMask, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m UpdateProjectRequest_SdkV2) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + "project": basetypes.ListType{ + ElemType: Project_SdkV2{}.Type(ctx), + }, + "update_mask": types.StringType, + }, + } +} + +// GetProject returns the value of the Project field in UpdateProjectRequest_SdkV2 as +// a Project_SdkV2 value. +// If the field is unknown or null, the boolean return value is false. +func (m *UpdateProjectRequest_SdkV2) GetProject(ctx context.Context) (Project_SdkV2, bool) { + var e Project_SdkV2 + if m.Project.IsNull() || m.Project.IsUnknown() { + return e, false + } + var v []Project_SdkV2 + d := m.Project.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + if len(v) == 0 { + return e, false + } + return v[0], true +} + +// SetProject sets the value of the Project field in UpdateProjectRequest_SdkV2. +func (m *UpdateProjectRequest_SdkV2) SetProject(ctx context.Context, v Project_SdkV2) { + vs := []attr.Value{v.ToObjectValue(ctx)} + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["project"] + m.Project = types.ListValueMust(t, vs) +} diff --git a/internal/service/postgres_tf/model.go b/internal/service/postgres_tf/model.go new file mode 100755 index 0000000000..3119da9028 --- /dev/null +++ b/internal/service/postgres_tf/model.go @@ -0,0 +1,2962 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. +/* +These generated types are for terraform plugin framework to interact with the terraform state conveniently. + +These types follow the same structure as the types in go-sdk. +The only difference is that the primitive types are no longer using the go-native types, but with tfsdk types. +Plus the json tags get converted into tfsdk tags. +We use go-native types for lists and maps intentionally for the ease for converting these types into the go-sdk types. +*/ + +package postgres_tf + +import ( + "context" + "reflect" + + pluginfwcommon "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/common" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema" + + "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/float64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +type Branch struct { + // A timestamp indicating when the branch was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + // The branch's state, indicating if it is initializing, ready for use, or + // archived. + CurrentState types.String `tfsdk:"current_state"` + // Whether the branch is the project's default branch. This field is only + // returned on create/update responses. See effective_default for the value + // that is actually applied to the branch. + Default types.Bool `tfsdk:"default"` + // Whether the branch is the project's default branch. + EffectiveDefault types.Bool `tfsdk:"effective_default"` + // Whether the branch is protected. + EffectiveIsProtected types.Bool `tfsdk:"effective_is_protected"` + // The name of the source branch from which this branch was created. Format: + // projects/{project_id}/branches/{branch_id} + EffectiveSourceBranch types.String `tfsdk:"effective_source_branch"` + // The Log Sequence Number (LSN) on the source branch from which this branch + // was created. + EffectiveSourceBranchLsn types.String `tfsdk:"effective_source_branch_lsn"` + // The point in time on the source branch from which this branch was + // created. + EffectiveSourceBranchTime timetypes.RFC3339 `tfsdk:"effective_source_branch_time"` + // Whether the branch is protected. + IsProtected types.Bool `tfsdk:"is_protected"` + // The logical size of the branch. + LogicalSizeBytes types.Int64 `tfsdk:"logical_size_bytes"` + // The resource name of the branch. Format: + // projects/{project_id}/branches/{branch_id} + Name types.String `tfsdk:"name"` + // The project containing this branch. Format: projects/{project_id} + Parent types.String `tfsdk:"parent"` + // The pending state of the branch, if a state transition is in progress. + PendingState types.String `tfsdk:"pending_state"` + // The name of the source branch from which this branch was created. Format: + // projects/{project_id}/branches/{branch_id} + SourceBranch types.String `tfsdk:"source_branch"` + // The Log Sequence Number (LSN) on the source branch from which this branch + // was created. + SourceBranchLsn types.String `tfsdk:"source_branch_lsn"` + // The point in time on the source branch from which this branch was + // created. + SourceBranchTime timetypes.RFC3339 `tfsdk:"source_branch_time"` + // A timestamp indicating when the `current_state` began. + StateChangeTime timetypes.RFC3339 `tfsdk:"state_change_time"` + // System generated unique ID for the branch. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the branch was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +func (to *Branch) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Branch) { + if !from.Default.IsUnknown() && !from.Default.IsNull() { + // Default is an input only field and not returned by the service, so we keep the value from the prior state. + to.Default = from.Default + } + if !from.IsProtected.IsUnknown() && !from.IsProtected.IsNull() { + // IsProtected is an input only field and not returned by the service, so we keep the value from the prior state. + to.IsProtected = from.IsProtected + } + if !from.SourceBranch.IsUnknown() && !from.SourceBranch.IsNull() { + // SourceBranch is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranch = from.SourceBranch + } + if !from.SourceBranchLsn.IsUnknown() && !from.SourceBranchLsn.IsNull() { + // SourceBranchLsn is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchLsn = from.SourceBranchLsn + } + if !from.SourceBranchTime.IsUnknown() && !from.SourceBranchTime.IsNull() { + // SourceBranchTime is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchTime = from.SourceBranchTime + } +} + +func (to *Branch) SyncFieldsDuringRead(ctx context.Context, from Branch) { + if !from.Default.IsUnknown() && !from.Default.IsNull() { + // Default is an input only field and not returned by the service, so we keep the value from the prior state. + to.Default = from.Default + } + if !from.IsProtected.IsUnknown() && !from.IsProtected.IsNull() { + // IsProtected is an input only field and not returned by the service, so we keep the value from the prior state. + to.IsProtected = from.IsProtected + } + if !from.SourceBranch.IsUnknown() && !from.SourceBranch.IsNull() { + // SourceBranch is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranch = from.SourceBranch + } + if !from.SourceBranchLsn.IsUnknown() && !from.SourceBranchLsn.IsNull() { + // SourceBranchLsn is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchLsn = from.SourceBranchLsn + } + if !from.SourceBranchTime.IsUnknown() && !from.SourceBranchTime.IsNull() { + // SourceBranchTime is an input only field and not returned by the service, so we keep the value from the prior state. + to.SourceBranchTime = from.SourceBranchTime + } +} + +func (m Branch) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["current_state"] = attrs["current_state"].SetComputed() + attrs["default"] = attrs["default"].SetOptional() + attrs["default"] = attrs["default"].SetComputed() + attrs["default"] = attrs["default"].(tfschema.BoolAttributeBuilder).AddPlanModifier(boolplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["effective_default"] = attrs["effective_default"].SetComputed() + attrs["effective_is_protected"] = attrs["effective_is_protected"].SetComputed() + attrs["effective_source_branch"] = attrs["effective_source_branch"].SetComputed() + attrs["effective_source_branch_lsn"] = attrs["effective_source_branch_lsn"].SetComputed() + attrs["effective_source_branch_time"] = attrs["effective_source_branch_time"].SetComputed() + attrs["is_protected"] = attrs["is_protected"].SetOptional() + attrs["is_protected"] = attrs["is_protected"].SetComputed() + attrs["is_protected"] = attrs["is_protected"].(tfschema.BoolAttributeBuilder).AddPlanModifier(boolplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["logical_size_bytes"] = attrs["logical_size_bytes"].SetComputed() + attrs["name"] = attrs["name"].SetOptional() + attrs["parent"] = attrs["parent"].SetComputed() + attrs["pending_state"] = attrs["pending_state"].SetComputed() + attrs["source_branch"] = attrs["source_branch"].SetOptional() + attrs["source_branch"] = attrs["source_branch"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["source_branch"] = attrs["source_branch"].SetComputed() + attrs["source_branch"] = attrs["source_branch"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].SetOptional() + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].SetComputed() + attrs["source_branch_lsn"] = attrs["source_branch_lsn"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["source_branch_time"] = attrs["source_branch_time"].SetOptional() + attrs["source_branch_time"] = attrs["source_branch_time"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["source_branch_time"] = attrs["source_branch_time"].SetComputed() + attrs["source_branch_time"] = attrs["source_branch_time"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["state_change_time"] = attrs["state_change_time"].SetComputed() + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in Branch. +// 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 (m Branch) 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, Branch +// only implements ToObjectValue() and Type(). +func (m Branch) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "create_time": m.CreateTime, + "current_state": m.CurrentState, + "default": m.Default, + "effective_default": m.EffectiveDefault, + "effective_is_protected": m.EffectiveIsProtected, + "effective_source_branch": m.EffectiveSourceBranch, + "effective_source_branch_lsn": m.EffectiveSourceBranchLsn, + "effective_source_branch_time": m.EffectiveSourceBranchTime, + "is_protected": m.IsProtected, + "logical_size_bytes": m.LogicalSizeBytes, + "name": m.Name, + "parent": m.Parent, + "pending_state": m.PendingState, + "source_branch": m.SourceBranch, + "source_branch_lsn": m.SourceBranchLsn, + "source_branch_time": m.SourceBranchTime, + "state_change_time": m.StateChangeTime, + "uid": m.Uid, + "update_time": m.UpdateTime, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m Branch) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "create_time": timetypes.RFC3339{}.Type(ctx), + "current_state": types.StringType, + "default": types.BoolType, + "effective_default": types.BoolType, + "effective_is_protected": types.BoolType, + "effective_source_branch": types.StringType, + "effective_source_branch_lsn": types.StringType, + "effective_source_branch_time": timetypes.RFC3339{}.Type(ctx), + "is_protected": types.BoolType, + "logical_size_bytes": types.Int64Type, + "name": types.StringType, + "parent": types.StringType, + "pending_state": types.StringType, + "source_branch": types.StringType, + "source_branch_lsn": types.StringType, + "source_branch_time": timetypes.RFC3339{}.Type(ctx), + "state_change_time": timetypes.RFC3339{}.Type(ctx), + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +type BranchOperationMetadata struct { +} + +func (to *BranchOperationMetadata) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from BranchOperationMetadata) { +} + +func (to *BranchOperationMetadata) SyncFieldsDuringRead(ctx context.Context, from BranchOperationMetadata) { +} + +func (m BranchOperationMetadata) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in BranchOperationMetadata. +// 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 (m BranchOperationMetadata) 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, BranchOperationMetadata +// only implements ToObjectValue() and Type(). +func (m BranchOperationMetadata) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{}) +} + +// Type implements basetypes.ObjectValuable. +func (m BranchOperationMetadata) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{}, + } +} + +type CreateBranchRequest struct { + // The Branch to create. + Branch types.Object `tfsdk:"branch"` + // The ID to use for the Branch, which will become the final component of + // the branch's resource name. + // + // This value should be 4-63 characters, and valid characters are + // /[a-z][0-9]-/. + BranchId types.String `tfsdk:"-"` + // The Project where this Branch will be created. Format: + // projects/{project_id} + Parent types.String `tfsdk:"-"` +} + +func (to *CreateBranchRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from CreateBranchRequest) { + if !from.Branch.IsNull() && !from.Branch.IsUnknown() { + if toBranch, ok := to.GetBranch(ctx); ok { + if fromBranch, ok := from.GetBranch(ctx); ok { + // Recursively sync the fields of Branch + toBranch.SyncFieldsDuringCreateOrUpdate(ctx, fromBranch) + to.SetBranch(ctx, toBranch) + } + } + } +} + +func (to *CreateBranchRequest) SyncFieldsDuringRead(ctx context.Context, from CreateBranchRequest) { + if !from.Branch.IsNull() && !from.Branch.IsUnknown() { + if toBranch, ok := to.GetBranch(ctx); ok { + if fromBranch, ok := from.GetBranch(ctx); ok { + toBranch.SyncFieldsDuringRead(ctx, fromBranch) + to.SetBranch(ctx, toBranch) + } + } + } +} + +func (m CreateBranchRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["branch"] = attrs["branch"].SetRequired() + attrs["parent"] = attrs["parent"].SetRequired() + attrs["branch_id"] = attrs["branch_id"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in CreateBranchRequest. +// 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 (m CreateBranchRequest) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "branch": reflect.TypeOf(Branch{}), + } +} + +// 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, CreateBranchRequest +// only implements ToObjectValue() and Type(). +func (m CreateBranchRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "branch": m.Branch, + "branch_id": m.BranchId, + "parent": m.Parent, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m CreateBranchRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "branch": Branch{}.Type(ctx), + "branch_id": types.StringType, + "parent": types.StringType, + }, + } +} + +// GetBranch returns the value of the Branch field in CreateBranchRequest as +// a Branch value. +// If the field is unknown or null, the boolean return value is false. +func (m *CreateBranchRequest) GetBranch(ctx context.Context) (Branch, bool) { + var e Branch + if m.Branch.IsNull() || m.Branch.IsUnknown() { + return e, false + } + var v Branch + d := m.Branch.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetBranch sets the value of the Branch field in CreateBranchRequest. +func (m *CreateBranchRequest) SetBranch(ctx context.Context, v Branch) { + vs := v.ToObjectValue(ctx) + m.Branch = vs +} + +type CreateEndpointRequest struct { + // The Endpoint to create. + Endpoint types.Object `tfsdk:"endpoint"` + // The ID to use for the Endpoint, which will become the final component of + // the endpoint's resource name. + // + // This value should be 4-63 characters, and valid characters are + // /[a-z][0-9]-/. + EndpointId types.String `tfsdk:"-"` + // The Branch where this Endpoint will be created. Format: + // projects/{project_id}/branches/{branch_id} + Parent types.String `tfsdk:"-"` +} + +func (to *CreateEndpointRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from CreateEndpointRequest) { + if !from.Endpoint.IsNull() && !from.Endpoint.IsUnknown() { + if toEndpoint, ok := to.GetEndpoint(ctx); ok { + if fromEndpoint, ok := from.GetEndpoint(ctx); ok { + // Recursively sync the fields of Endpoint + toEndpoint.SyncFieldsDuringCreateOrUpdate(ctx, fromEndpoint) + to.SetEndpoint(ctx, toEndpoint) + } + } + } +} + +func (to *CreateEndpointRequest) SyncFieldsDuringRead(ctx context.Context, from CreateEndpointRequest) { + if !from.Endpoint.IsNull() && !from.Endpoint.IsUnknown() { + if toEndpoint, ok := to.GetEndpoint(ctx); ok { + if fromEndpoint, ok := from.GetEndpoint(ctx); ok { + toEndpoint.SyncFieldsDuringRead(ctx, fromEndpoint) + to.SetEndpoint(ctx, toEndpoint) + } + } + } +} + +func (m CreateEndpointRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["endpoint"] = attrs["endpoint"].SetRequired() + attrs["parent"] = attrs["parent"].SetRequired() + attrs["endpoint_id"] = attrs["endpoint_id"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in CreateEndpointRequest. +// 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 (m CreateEndpointRequest) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "endpoint": reflect.TypeOf(Endpoint{}), + } +} + +// 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, CreateEndpointRequest +// only implements ToObjectValue() and Type(). +func (m CreateEndpointRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "endpoint": m.Endpoint, + "endpoint_id": m.EndpointId, + "parent": m.Parent, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m CreateEndpointRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "endpoint": Endpoint{}.Type(ctx), + "endpoint_id": types.StringType, + "parent": types.StringType, + }, + } +} + +// GetEndpoint returns the value of the Endpoint field in CreateEndpointRequest as +// a Endpoint value. +// If the field is unknown or null, the boolean return value is false. +func (m *CreateEndpointRequest) GetEndpoint(ctx context.Context) (Endpoint, bool) { + var e Endpoint + if m.Endpoint.IsNull() || m.Endpoint.IsUnknown() { + return e, false + } + var v Endpoint + d := m.Endpoint.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetEndpoint sets the value of the Endpoint field in CreateEndpointRequest. +func (m *CreateEndpointRequest) SetEndpoint(ctx context.Context, v Endpoint) { + vs := v.ToObjectValue(ctx) + m.Endpoint = vs +} + +type CreateProjectRequest struct { + // The Project to create. + Project types.Object `tfsdk:"project"` + // The ID to use for the Project, which will become the final component of + // the project's resource name. + // + // This value should be 4-63 characters, and valid characters are + // /[a-z][0-9]-/. + ProjectId types.String `tfsdk:"-"` +} + +func (to *CreateProjectRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from CreateProjectRequest) { + if !from.Project.IsNull() && !from.Project.IsUnknown() { + if toProject, ok := to.GetProject(ctx); ok { + if fromProject, ok := from.GetProject(ctx); ok { + // Recursively sync the fields of Project + toProject.SyncFieldsDuringCreateOrUpdate(ctx, fromProject) + to.SetProject(ctx, toProject) + } + } + } +} + +func (to *CreateProjectRequest) SyncFieldsDuringRead(ctx context.Context, from CreateProjectRequest) { + if !from.Project.IsNull() && !from.Project.IsUnknown() { + if toProject, ok := to.GetProject(ctx); ok { + if fromProject, ok := from.GetProject(ctx); ok { + toProject.SyncFieldsDuringRead(ctx, fromProject) + to.SetProject(ctx, toProject) + } + } + } +} + +func (m CreateProjectRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["project"] = attrs["project"].SetRequired() + attrs["project_id"] = attrs["project_id"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in CreateProjectRequest. +// 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 (m CreateProjectRequest) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "project": reflect.TypeOf(Project{}), + } +} + +// 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, CreateProjectRequest +// only implements ToObjectValue() and Type(). +func (m CreateProjectRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "project": m.Project, + "project_id": m.ProjectId, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m CreateProjectRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "project": Project{}.Type(ctx), + "project_id": types.StringType, + }, + } +} + +// GetProject returns the value of the Project field in CreateProjectRequest as +// a Project value. +// If the field is unknown or null, the boolean return value is false. +func (m *CreateProjectRequest) GetProject(ctx context.Context) (Project, bool) { + var e Project + if m.Project.IsNull() || m.Project.IsUnknown() { + return e, false + } + var v Project + d := m.Project.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetProject sets the value of the Project field in CreateProjectRequest. +func (m *CreateProjectRequest) SetProject(ctx context.Context, v Project) { + vs := v.ToObjectValue(ctx) + m.Project = vs +} + +// Databricks Error that is returned by all Databricks APIs. +type DatabricksServiceExceptionWithDetailsProto struct { + // @pbjson-skip + Details types.List `tfsdk:"details"` + + ErrorCode types.String `tfsdk:"error_code"` + + Message types.String `tfsdk:"message"` + + StackTrace types.String `tfsdk:"stack_trace"` +} + +func (to *DatabricksServiceExceptionWithDetailsProto) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from DatabricksServiceExceptionWithDetailsProto) { + if !from.Details.IsNull() && !from.Details.IsUnknown() && to.Details.IsNull() && len(from.Details.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Details, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Details = from.Details + } +} + +func (to *DatabricksServiceExceptionWithDetailsProto) SyncFieldsDuringRead(ctx context.Context, from DatabricksServiceExceptionWithDetailsProto) { + if !from.Details.IsNull() && !from.Details.IsUnknown() && to.Details.IsNull() && len(from.Details.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Details, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Details = from.Details + } +} + +func (m DatabricksServiceExceptionWithDetailsProto) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["details"] = attrs["details"].SetOptional() + attrs["error_code"] = attrs["error_code"].SetOptional() + attrs["message"] = attrs["message"].SetOptional() + attrs["stack_trace"] = attrs["stack_trace"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in DatabricksServiceExceptionWithDetailsProto. +// 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 (m DatabricksServiceExceptionWithDetailsProto) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "details": reflect.TypeOf(types.Object{}), + } +} + +// 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, DatabricksServiceExceptionWithDetailsProto +// only implements ToObjectValue() and Type(). +func (m DatabricksServiceExceptionWithDetailsProto) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "details": m.Details, + "error_code": m.ErrorCode, + "message": m.Message, + "stack_trace": m.StackTrace, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m DatabricksServiceExceptionWithDetailsProto) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "details": basetypes.ListType{ + ElemType: types.ObjectType{}, + }, + "error_code": types.StringType, + "message": types.StringType, + "stack_trace": types.StringType, + }, + } +} + +// GetDetails returns the value of the Details field in DatabricksServiceExceptionWithDetailsProto as +// a slice of types.Object values. +// If the field is unknown or null, the boolean return value is false. +func (m *DatabricksServiceExceptionWithDetailsProto) GetDetails(ctx context.Context) ([]types.Object, bool) { + if m.Details.IsNull() || m.Details.IsUnknown() { + return nil, false + } + var v []types.Object + d := m.Details.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetDetails sets the value of the Details field in DatabricksServiceExceptionWithDetailsProto. +func (m *DatabricksServiceExceptionWithDetailsProto) SetDetails(ctx context.Context, v []types.Object) { + vs := make([]attr.Value, 0, len(v)) + for _, e := range v { + vs = append(vs, e) + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["details"] + t = t.(attr.TypeWithElementType).ElementType() + m.Details = types.ListValueMust(t, vs) +} + +type DeleteBranchRequest struct { + // The name of the Branch to delete. Format: + // projects/{project_id}/branches/{branch_id} + Name types.String `tfsdk:"-"` +} + +func (to *DeleteBranchRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from DeleteBranchRequest) { +} + +func (to *DeleteBranchRequest) SyncFieldsDuringRead(ctx context.Context, from DeleteBranchRequest) { +} + +func (m DeleteBranchRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in DeleteBranchRequest. +// 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 (m DeleteBranchRequest) 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, DeleteBranchRequest +// only implements ToObjectValue() and Type(). +func (m DeleteBranchRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m DeleteBranchRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type DeleteEndpointRequest struct { + // The name of the Endpoint to delete. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name types.String `tfsdk:"-"` +} + +func (to *DeleteEndpointRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from DeleteEndpointRequest) { +} + +func (to *DeleteEndpointRequest) SyncFieldsDuringRead(ctx context.Context, from DeleteEndpointRequest) { +} + +func (m DeleteEndpointRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in DeleteEndpointRequest. +// 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 (m DeleteEndpointRequest) 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, DeleteEndpointRequest +// only implements ToObjectValue() and Type(). +func (m DeleteEndpointRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m DeleteEndpointRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type DeleteProjectRequest struct { + // The name of the Project to delete. Format: projects/{project_id} + Name types.String `tfsdk:"-"` +} + +func (to *DeleteProjectRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from DeleteProjectRequest) { +} + +func (to *DeleteProjectRequest) SyncFieldsDuringRead(ctx context.Context, from DeleteProjectRequest) { +} + +func (m DeleteProjectRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in DeleteProjectRequest. +// 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 (m DeleteProjectRequest) 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, DeleteProjectRequest +// only implements ToObjectValue() and Type(). +func (m DeleteProjectRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m DeleteProjectRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type Endpoint struct { + // The maximum number of Compute Units. + AutoscalingLimitMaxCu types.Float64 `tfsdk:"autoscaling_limit_max_cu"` + // The minimum number of Compute Units. + AutoscalingLimitMinCu types.Float64 `tfsdk:"autoscaling_limit_min_cu"` + // A timestamp indicating when the compute endpoint was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + + CurrentState types.String `tfsdk:"current_state"` + // Whether to restrict connections to the compute endpoint. Enabling this + // option schedules a suspend compute operation. A disabled compute endpoint + // cannot be enabled by a connection or console action. + Disabled types.Bool `tfsdk:"disabled"` + // The maximum number of Compute Units. + EffectiveAutoscalingLimitMaxCu types.Float64 `tfsdk:"effective_autoscaling_limit_max_cu"` + // The minimum number of Compute Units. + EffectiveAutoscalingLimitMinCu types.Float64 `tfsdk:"effective_autoscaling_limit_min_cu"` + // Whether to restrict connections to the compute endpoint. Enabling this + // option schedules a suspend compute operation. A disabled compute endpoint + // cannot be enabled by a connection or console action. + EffectiveDisabled types.Bool `tfsdk:"effective_disabled"` + + EffectivePoolerMode types.String `tfsdk:"effective_pooler_mode"` + + EffectiveSettings types.Object `tfsdk:"effective_settings"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + EffectiveSuspendTimeoutDuration timetypes.GoDuration `tfsdk:"effective_suspend_timeout_duration"` + // The endpoint type. There could be only one READ_WRITE endpoint per + // branch. + EndpointType types.String `tfsdk:"endpoint_type"` + // The hostname of the compute endpoint. This is the hostname specified when + // connecting to a database. + Host types.String `tfsdk:"host"` + // A timestamp indicating when the compute endpoint was last active. + LastActiveTime timetypes.RFC3339 `tfsdk:"last_active_time"` + // The resource name of the endpoint. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name types.String `tfsdk:"name"` + // The branch containing this endpoint. Format: + // projects/{project_id}/branches/{branch_id} + Parent types.String `tfsdk:"parent"` + + PendingState types.String `tfsdk:"pending_state"` + + PoolerMode types.String `tfsdk:"pooler_mode"` + + Settings types.Object `tfsdk:"settings"` + // A timestamp indicating when the compute endpoint was last started. + StartTime timetypes.RFC3339 `tfsdk:"start_time"` + // A timestamp indicating when the compute endpoint was last suspended. + SuspendTime timetypes.RFC3339 `tfsdk:"suspend_time"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + SuspendTimeoutDuration timetypes.GoDuration `tfsdk:"suspend_timeout_duration"` + // System generated unique ID for the endpoint. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the compute endpoint was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +func (to *Endpoint) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Endpoint) { + if !from.AutoscalingLimitMaxCu.IsUnknown() && !from.AutoscalingLimitMaxCu.IsNull() { + // AutoscalingLimitMaxCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMaxCu = from.AutoscalingLimitMaxCu + } + if !from.AutoscalingLimitMinCu.IsUnknown() && !from.AutoscalingLimitMinCu.IsNull() { + // AutoscalingLimitMinCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMinCu = from.AutoscalingLimitMinCu + } + if !from.Disabled.IsUnknown() && !from.Disabled.IsNull() { + // Disabled is an input only field and not returned by the service, so we keep the value from the prior state. + to.Disabled = from.Disabled + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + // Recursively sync the fields of EffectiveSettings + toEffectiveSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + if !from.PoolerMode.IsUnknown() && !from.PoolerMode.IsNull() { + // PoolerMode is an input only field and not returned by the service, so we keep the value from the prior state. + to.PoolerMode = from.PoolerMode + } + if !from.Settings.IsUnknown() && !from.Settings.IsNull() { + // Settings is an input only field and not returned by the service, so we keep the value from the prior state. + to.Settings = from.Settings + } + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + // Recursively sync the fields of Settings + toSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } + if !from.SuspendTimeoutDuration.IsUnknown() && !from.SuspendTimeoutDuration.IsNull() { + // SuspendTimeoutDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.SuspendTimeoutDuration = from.SuspendTimeoutDuration + } +} + +func (to *Endpoint) SyncFieldsDuringRead(ctx context.Context, from Endpoint) { + if !from.AutoscalingLimitMaxCu.IsUnknown() && !from.AutoscalingLimitMaxCu.IsNull() { + // AutoscalingLimitMaxCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMaxCu = from.AutoscalingLimitMaxCu + } + if !from.AutoscalingLimitMinCu.IsUnknown() && !from.AutoscalingLimitMinCu.IsNull() { + // AutoscalingLimitMinCu is an input only field and not returned by the service, so we keep the value from the prior state. + to.AutoscalingLimitMinCu = from.AutoscalingLimitMinCu + } + if !from.Disabled.IsUnknown() && !from.Disabled.IsNull() { + // Disabled is an input only field and not returned by the service, so we keep the value from the prior state. + to.Disabled = from.Disabled + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + toEffectiveSettings.SyncFieldsDuringRead(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + if !from.PoolerMode.IsUnknown() && !from.PoolerMode.IsNull() { + // PoolerMode is an input only field and not returned by the service, so we keep the value from the prior state. + to.PoolerMode = from.PoolerMode + } + if !from.Settings.IsUnknown() && !from.Settings.IsNull() { + // Settings is an input only field and not returned by the service, so we keep the value from the prior state. + to.Settings = from.Settings + } + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + toSettings.SyncFieldsDuringRead(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } + if !from.SuspendTimeoutDuration.IsUnknown() && !from.SuspendTimeoutDuration.IsNull() { + // SuspendTimeoutDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.SuspendTimeoutDuration = from.SuspendTimeoutDuration + } +} + +func (m Endpoint) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].SetOptional() + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].SetComputed() + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].(tfschema.Float64AttributeBuilder).AddPlanModifier(float64planmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].SetOptional() + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].SetComputed() + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].(tfschema.Float64AttributeBuilder).AddPlanModifier(float64planmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["current_state"] = attrs["current_state"].SetComputed() + attrs["disabled"] = attrs["disabled"].SetOptional() + attrs["disabled"] = attrs["disabled"].SetComputed() + attrs["disabled"] = attrs["disabled"].(tfschema.BoolAttributeBuilder).AddPlanModifier(boolplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["effective_autoscaling_limit_max_cu"] = attrs["effective_autoscaling_limit_max_cu"].SetComputed() + attrs["effective_autoscaling_limit_min_cu"] = attrs["effective_autoscaling_limit_min_cu"].SetComputed() + attrs["effective_disabled"] = attrs["effective_disabled"].SetComputed() + attrs["effective_pooler_mode"] = attrs["effective_pooler_mode"].SetComputed() + attrs["effective_settings"] = attrs["effective_settings"].SetComputed() + attrs["effective_suspend_timeout_duration"] = attrs["effective_suspend_timeout_duration"].SetComputed() + attrs["endpoint_type"] = attrs["endpoint_type"].SetRequired() + attrs["endpoint_type"] = attrs["endpoint_type"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["host"] = attrs["host"].SetComputed() + attrs["last_active_time"] = attrs["last_active_time"].SetComputed() + attrs["name"] = attrs["name"].SetOptional() + attrs["parent"] = attrs["parent"].SetComputed() + attrs["pending_state"] = attrs["pending_state"].SetComputed() + attrs["pooler_mode"] = attrs["pooler_mode"].SetOptional() + attrs["pooler_mode"] = attrs["pooler_mode"].SetComputed() + attrs["pooler_mode"] = attrs["pooler_mode"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["settings"] = attrs["settings"].SetOptional() + attrs["settings"] = attrs["settings"].SetComputed() + attrs["settings"] = attrs["settings"].(tfschema.SingleNestedAttributeBuilder).AddPlanModifier(objectplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["start_time"] = attrs["start_time"].SetComputed() + attrs["suspend_time"] = attrs["suspend_time"].SetComputed() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].SetOptional() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].SetComputed() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in Endpoint. +// 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 (m Endpoint) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "effective_settings": reflect.TypeOf(EndpointSettings{}), + "settings": reflect.TypeOf(EndpointSettings{}), + } +} + +// 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, Endpoint +// only implements ToObjectValue() and Type(). +func (m Endpoint) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "autoscaling_limit_max_cu": m.AutoscalingLimitMaxCu, + "autoscaling_limit_min_cu": m.AutoscalingLimitMinCu, + "create_time": m.CreateTime, + "current_state": m.CurrentState, + "disabled": m.Disabled, + "effective_autoscaling_limit_max_cu": m.EffectiveAutoscalingLimitMaxCu, + "effective_autoscaling_limit_min_cu": m.EffectiveAutoscalingLimitMinCu, + "effective_disabled": m.EffectiveDisabled, + "effective_pooler_mode": m.EffectivePoolerMode, + "effective_settings": m.EffectiveSettings, + "effective_suspend_timeout_duration": m.EffectiveSuspendTimeoutDuration, + "endpoint_type": m.EndpointType, + "host": m.Host, + "last_active_time": m.LastActiveTime, + "name": m.Name, + "parent": m.Parent, + "pending_state": m.PendingState, + "pooler_mode": m.PoolerMode, + "settings": m.Settings, + "start_time": m.StartTime, + "suspend_time": m.SuspendTime, + "suspend_timeout_duration": m.SuspendTimeoutDuration, + "uid": m.Uid, + "update_time": m.UpdateTime, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m Endpoint) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "autoscaling_limit_max_cu": types.Float64Type, + "autoscaling_limit_min_cu": types.Float64Type, + "create_time": timetypes.RFC3339{}.Type(ctx), + "current_state": types.StringType, + "disabled": types.BoolType, + "effective_autoscaling_limit_max_cu": types.Float64Type, + "effective_autoscaling_limit_min_cu": types.Float64Type, + "effective_disabled": types.BoolType, + "effective_pooler_mode": types.StringType, + "effective_settings": EndpointSettings{}.Type(ctx), + "effective_suspend_timeout_duration": timetypes.GoDuration{}.Type(ctx), + "endpoint_type": types.StringType, + "host": types.StringType, + "last_active_time": timetypes.RFC3339{}.Type(ctx), + "name": types.StringType, + "parent": types.StringType, + "pending_state": types.StringType, + "pooler_mode": types.StringType, + "settings": EndpointSettings{}.Type(ctx), + "start_time": timetypes.RFC3339{}.Type(ctx), + "suspend_time": timetypes.RFC3339{}.Type(ctx), + "suspend_timeout_duration": timetypes.GoDuration{}.Type(ctx), + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +// GetEffectiveSettings returns the value of the EffectiveSettings field in Endpoint as +// a EndpointSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Endpoint) GetEffectiveSettings(ctx context.Context) (EndpointSettings, bool) { + var e EndpointSettings + if m.EffectiveSettings.IsNull() || m.EffectiveSettings.IsUnknown() { + return e, false + } + var v EndpointSettings + d := m.EffectiveSettings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetEffectiveSettings sets the value of the EffectiveSettings field in Endpoint. +func (m *Endpoint) SetEffectiveSettings(ctx context.Context, v EndpointSettings) { + vs := v.ToObjectValue(ctx) + m.EffectiveSettings = vs +} + +// GetSettings returns the value of the Settings field in Endpoint as +// a EndpointSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Endpoint) GetSettings(ctx context.Context) (EndpointSettings, bool) { + var e EndpointSettings + if m.Settings.IsNull() || m.Settings.IsUnknown() { + return e, false + } + var v EndpointSettings + d := m.Settings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetSettings sets the value of the Settings field in Endpoint. +func (m *Endpoint) SetSettings(ctx context.Context, v EndpointSettings) { + vs := v.ToObjectValue(ctx) + m.Settings = vs +} + +type EndpointOperationMetadata struct { +} + +func (to *EndpointOperationMetadata) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from EndpointOperationMetadata) { +} + +func (to *EndpointOperationMetadata) SyncFieldsDuringRead(ctx context.Context, from EndpointOperationMetadata) { +} + +func (m EndpointOperationMetadata) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in EndpointOperationMetadata. +// 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 (m EndpointOperationMetadata) 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, EndpointOperationMetadata +// only implements ToObjectValue() and Type(). +func (m EndpointOperationMetadata) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{}) +} + +// Type implements basetypes.ObjectValuable. +func (m EndpointOperationMetadata) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{}, + } +} + +// A collection of settings for a compute endpoint. +type EndpointSettings struct { + // A raw representation of Postgres settings. + PgSettings types.Map `tfsdk:"pg_settings"` + // A raw representation of PgBouncer settings. + PgbouncerSettings types.Map `tfsdk:"pgbouncer_settings"` +} + +func (to *EndpointSettings) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from EndpointSettings) { +} + +func (to *EndpointSettings) SyncFieldsDuringRead(ctx context.Context, from EndpointSettings) { +} + +func (m EndpointSettings) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["pg_settings"] = attrs["pg_settings"].SetOptional() + attrs["pgbouncer_settings"] = attrs["pgbouncer_settings"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in EndpointSettings. +// 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 (m EndpointSettings) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "pg_settings": reflect.TypeOf(types.String{}), + "pgbouncer_settings": reflect.TypeOf(types.String{}), + } +} + +// 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, EndpointSettings +// only implements ToObjectValue() and Type(). +func (m EndpointSettings) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "pg_settings": m.PgSettings, + "pgbouncer_settings": m.PgbouncerSettings, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m EndpointSettings) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "pg_settings": basetypes.MapType{ + ElemType: types.StringType, + }, + "pgbouncer_settings": basetypes.MapType{ + ElemType: types.StringType, + }, + }, + } +} + +// GetPgSettings returns the value of the PgSettings field in EndpointSettings as +// a map of string to types.String values. +// If the field is unknown or null, the boolean return value is false. +func (m *EndpointSettings) GetPgSettings(ctx context.Context) (map[string]types.String, bool) { + if m.PgSettings.IsNull() || m.PgSettings.IsUnknown() { + return nil, false + } + var v map[string]types.String + d := m.PgSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetPgSettings sets the value of the PgSettings field in EndpointSettings. +func (m *EndpointSettings) SetPgSettings(ctx context.Context, v map[string]types.String) { + vs := make(map[string]attr.Value, len(v)) + for k, e := range v { + vs[k] = e + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["pg_settings"] + t = t.(attr.TypeWithElementType).ElementType() + m.PgSettings = types.MapValueMust(t, vs) +} + +// GetPgbouncerSettings returns the value of the PgbouncerSettings field in EndpointSettings as +// a map of string to types.String values. +// If the field is unknown or null, the boolean return value is false. +func (m *EndpointSettings) GetPgbouncerSettings(ctx context.Context) (map[string]types.String, bool) { + if m.PgbouncerSettings.IsNull() || m.PgbouncerSettings.IsUnknown() { + return nil, false + } + var v map[string]types.String + d := m.PgbouncerSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetPgbouncerSettings sets the value of the PgbouncerSettings field in EndpointSettings. +func (m *EndpointSettings) SetPgbouncerSettings(ctx context.Context, v map[string]types.String) { + vs := make(map[string]attr.Value, len(v)) + for k, e := range v { + vs[k] = e + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["pgbouncer_settings"] + t = t.(attr.TypeWithElementType).ElementType() + m.PgbouncerSettings = types.MapValueMust(t, vs) +} + +type GetBranchRequest struct { + // The name of the Branch to retrieve. Format: + // projects/{project_id}/branches/{branch_id} + Name types.String `tfsdk:"-"` +} + +func (to *GetBranchRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from GetBranchRequest) { +} + +func (to *GetBranchRequest) SyncFieldsDuringRead(ctx context.Context, from GetBranchRequest) { +} + +func (m GetBranchRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in GetBranchRequest. +// 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 (m GetBranchRequest) 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, GetBranchRequest +// only implements ToObjectValue() and Type(). +func (m GetBranchRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m GetBranchRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type GetEndpointRequest struct { + // The name of the Endpoint to retrieve. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name types.String `tfsdk:"-"` +} + +func (to *GetEndpointRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from GetEndpointRequest) { +} + +func (to *GetEndpointRequest) SyncFieldsDuringRead(ctx context.Context, from GetEndpointRequest) { +} + +func (m GetEndpointRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in GetEndpointRequest. +// 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 (m GetEndpointRequest) 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, GetEndpointRequest +// only implements ToObjectValue() and Type(). +func (m GetEndpointRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m GetEndpointRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type GetOperationRequest struct { + // The name of the operation resource. + Name types.String `tfsdk:"-"` +} + +func (to *GetOperationRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from GetOperationRequest) { +} + +func (to *GetOperationRequest) SyncFieldsDuringRead(ctx context.Context, from GetOperationRequest) { +} + +func (m GetOperationRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in GetOperationRequest. +// 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 (m GetOperationRequest) 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, GetOperationRequest +// only implements ToObjectValue() and Type(). +func (m GetOperationRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m GetOperationRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type GetProjectRequest struct { + // The name of the Project to retrieve. Format: projects/{project_id} + Name types.String `tfsdk:"-"` +} + +func (to *GetProjectRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from GetProjectRequest) { +} + +func (to *GetProjectRequest) SyncFieldsDuringRead(ctx context.Context, from GetProjectRequest) { +} + +func (m GetProjectRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["name"] = attrs["name"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in GetProjectRequest. +// 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 (m GetProjectRequest) 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, GetProjectRequest +// only implements ToObjectValue() and Type(). +func (m GetProjectRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m GetProjectRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + }, + } +} + +type ListBranchesRequest struct { + // Upper bound for items returned. + PageSize types.Int64 `tfsdk:"-"` + // Pagination token to go to the next page of Branches. Requests first page + // if absent. + PageToken types.String `tfsdk:"-"` + // The Project that owns this collection of branches. Format: + // projects/{project_id} + Parent types.String `tfsdk:"-"` +} + +func (to *ListBranchesRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListBranchesRequest) { +} + +func (to *ListBranchesRequest) SyncFieldsDuringRead(ctx context.Context, from ListBranchesRequest) { +} + +func (m ListBranchesRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["parent"] = attrs["parent"].SetRequired() + attrs["page_token"] = attrs["page_token"].SetOptional() + attrs["page_size"] = attrs["page_size"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListBranchesRequest. +// 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 (m ListBranchesRequest) 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, ListBranchesRequest +// only implements ToObjectValue() and Type(). +func (m ListBranchesRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "page_size": m.PageSize, + "page_token": m.PageToken, + "parent": m.Parent, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListBranchesRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "page_size": types.Int64Type, + "page_token": types.StringType, + "parent": types.StringType, + }, + } +} + +type ListBranchesResponse struct { + // List of branches. + Branches types.List `tfsdk:"branches"` + // Pagination token to request the next page of branches. + NextPageToken types.String `tfsdk:"next_page_token"` +} + +func (to *ListBranchesResponse) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListBranchesResponse) { + if !from.Branches.IsNull() && !from.Branches.IsUnknown() && to.Branches.IsNull() && len(from.Branches.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Branches, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Branches = from.Branches + } +} + +func (to *ListBranchesResponse) SyncFieldsDuringRead(ctx context.Context, from ListBranchesResponse) { + if !from.Branches.IsNull() && !from.Branches.IsUnknown() && to.Branches.IsNull() && len(from.Branches.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Branches, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Branches = from.Branches + } +} + +func (m ListBranchesResponse) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["branches"] = attrs["branches"].SetOptional() + attrs["next_page_token"] = attrs["next_page_token"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListBranchesResponse. +// 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 (m ListBranchesResponse) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "branches": reflect.TypeOf(Branch{}), + } +} + +// 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, ListBranchesResponse +// only implements ToObjectValue() and Type(). +func (m ListBranchesResponse) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "branches": m.Branches, + "next_page_token": m.NextPageToken, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListBranchesResponse) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "branches": basetypes.ListType{ + ElemType: Branch{}.Type(ctx), + }, + "next_page_token": types.StringType, + }, + } +} + +// GetBranches returns the value of the Branches field in ListBranchesResponse as +// a slice of Branch values. +// If the field is unknown or null, the boolean return value is false. +func (m *ListBranchesResponse) GetBranches(ctx context.Context) ([]Branch, bool) { + if m.Branches.IsNull() || m.Branches.IsUnknown() { + return nil, false + } + var v []Branch + d := m.Branches.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetBranches sets the value of the Branches field in ListBranchesResponse. +func (m *ListBranchesResponse) SetBranches(ctx context.Context, v []Branch) { + vs := make([]attr.Value, 0, len(v)) + for _, e := range v { + vs = append(vs, e.ToObjectValue(ctx)) + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["branches"] + t = t.(attr.TypeWithElementType).ElementType() + m.Branches = types.ListValueMust(t, vs) +} + +type ListEndpointsRequest struct { + // Upper bound for items returned. + PageSize types.Int64 `tfsdk:"-"` + // Pagination token to go to the next page of Endpoints. Requests first page + // if absent. + PageToken types.String `tfsdk:"-"` + // The Branch that owns this collection of endpoints. Format: + // projects/{project_id}/branches/{branch_id} + Parent types.String `tfsdk:"-"` +} + +func (to *ListEndpointsRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListEndpointsRequest) { +} + +func (to *ListEndpointsRequest) SyncFieldsDuringRead(ctx context.Context, from ListEndpointsRequest) { +} + +func (m ListEndpointsRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["parent"] = attrs["parent"].SetRequired() + attrs["page_token"] = attrs["page_token"].SetOptional() + attrs["page_size"] = attrs["page_size"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListEndpointsRequest. +// 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 (m ListEndpointsRequest) 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, ListEndpointsRequest +// only implements ToObjectValue() and Type(). +func (m ListEndpointsRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "page_size": m.PageSize, + "page_token": m.PageToken, + "parent": m.Parent, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListEndpointsRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "page_size": types.Int64Type, + "page_token": types.StringType, + "parent": types.StringType, + }, + } +} + +type ListEndpointsResponse struct { + // List of endpoints. + Endpoints types.List `tfsdk:"endpoints"` + // Pagination token to request the next page of endpoints. + NextPageToken types.String `tfsdk:"next_page_token"` +} + +func (to *ListEndpointsResponse) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListEndpointsResponse) { + if !from.Endpoints.IsNull() && !from.Endpoints.IsUnknown() && to.Endpoints.IsNull() && len(from.Endpoints.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Endpoints, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Endpoints = from.Endpoints + } +} + +func (to *ListEndpointsResponse) SyncFieldsDuringRead(ctx context.Context, from ListEndpointsResponse) { + if !from.Endpoints.IsNull() && !from.Endpoints.IsUnknown() && to.Endpoints.IsNull() && len(from.Endpoints.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Endpoints, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Endpoints = from.Endpoints + } +} + +func (m ListEndpointsResponse) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["endpoints"] = attrs["endpoints"].SetOptional() + attrs["next_page_token"] = attrs["next_page_token"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListEndpointsResponse. +// 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 (m ListEndpointsResponse) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "endpoints": reflect.TypeOf(Endpoint{}), + } +} + +// 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, ListEndpointsResponse +// only implements ToObjectValue() and Type(). +func (m ListEndpointsResponse) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "endpoints": m.Endpoints, + "next_page_token": m.NextPageToken, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListEndpointsResponse) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "endpoints": basetypes.ListType{ + ElemType: Endpoint{}.Type(ctx), + }, + "next_page_token": types.StringType, + }, + } +} + +// GetEndpoints returns the value of the Endpoints field in ListEndpointsResponse as +// a slice of Endpoint values. +// If the field is unknown or null, the boolean return value is false. +func (m *ListEndpointsResponse) GetEndpoints(ctx context.Context) ([]Endpoint, bool) { + if m.Endpoints.IsNull() || m.Endpoints.IsUnknown() { + return nil, false + } + var v []Endpoint + d := m.Endpoints.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetEndpoints sets the value of the Endpoints field in ListEndpointsResponse. +func (m *ListEndpointsResponse) SetEndpoints(ctx context.Context, v []Endpoint) { + vs := make([]attr.Value, 0, len(v)) + for _, e := range v { + vs = append(vs, e.ToObjectValue(ctx)) + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["endpoints"] + t = t.(attr.TypeWithElementType).ElementType() + m.Endpoints = types.ListValueMust(t, vs) +} + +type ListProjectsRequest struct { + // Upper bound for items returned. + PageSize types.Int64 `tfsdk:"-"` + // Pagination token to go to the next page of Projects. Requests first page + // if absent. + PageToken types.String `tfsdk:"-"` +} + +func (to *ListProjectsRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListProjectsRequest) { +} + +func (to *ListProjectsRequest) SyncFieldsDuringRead(ctx context.Context, from ListProjectsRequest) { +} + +func (m ListProjectsRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["page_token"] = attrs["page_token"].SetOptional() + attrs["page_size"] = attrs["page_size"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListProjectsRequest. +// 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 (m ListProjectsRequest) 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, ListProjectsRequest +// only implements ToObjectValue() and Type(). +func (m ListProjectsRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "page_size": m.PageSize, + "page_token": m.PageToken, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListProjectsRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "page_size": types.Int64Type, + "page_token": types.StringType, + }, + } +} + +type ListProjectsResponse struct { + // Pagination token to request the next page of projects. + NextPageToken types.String `tfsdk:"next_page_token"` + // List of projects. + Projects types.List `tfsdk:"projects"` +} + +func (to *ListProjectsResponse) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ListProjectsResponse) { + if !from.Projects.IsNull() && !from.Projects.IsUnknown() && to.Projects.IsNull() && len(from.Projects.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Projects, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Projects = from.Projects + } +} + +func (to *ListProjectsResponse) SyncFieldsDuringRead(ctx context.Context, from ListProjectsResponse) { + if !from.Projects.IsNull() && !from.Projects.IsUnknown() && to.Projects.IsNull() && len(from.Projects.Elements()) == 0 { + // The default representation of an empty list for TF autogenerated resources in the resource state is Null. + // If a user specified a non-Null, empty list for Projects, and the deserialized field value is Null, + // set the resulting resource state to the empty list to match the planned value. + to.Projects = from.Projects + } +} + +func (m ListProjectsResponse) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["next_page_token"] = attrs["next_page_token"].SetOptional() + attrs["projects"] = attrs["projects"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ListProjectsResponse. +// 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 (m ListProjectsResponse) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "projects": reflect.TypeOf(Project{}), + } +} + +// 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, ListProjectsResponse +// only implements ToObjectValue() and Type(). +func (m ListProjectsResponse) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "next_page_token": m.NextPageToken, + "projects": m.Projects, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ListProjectsResponse) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "next_page_token": types.StringType, + "projects": basetypes.ListType{ + ElemType: Project{}.Type(ctx), + }, + }, + } +} + +// GetProjects returns the value of the Projects field in ListProjectsResponse as +// a slice of Project values. +// If the field is unknown or null, the boolean return value is false. +func (m *ListProjectsResponse) GetProjects(ctx context.Context) ([]Project, bool) { + if m.Projects.IsNull() || m.Projects.IsUnknown() { + return nil, false + } + var v []Project + d := m.Projects.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetProjects sets the value of the Projects field in ListProjectsResponse. +func (m *ListProjectsResponse) SetProjects(ctx context.Context, v []Project) { + vs := make([]attr.Value, 0, len(v)) + for _, e := range v { + vs = append(vs, e.ToObjectValue(ctx)) + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["projects"] + t = t.(attr.TypeWithElementType).ElementType() + m.Projects = types.ListValueMust(t, vs) +} + +// This resource represents a long-running operation that is the result of a +// network API call. +type Operation struct { + // If the value is `false`, it means the operation is still in progress. If + // `true`, the operation is completed, and either `error` or `response` is + // available. + Done types.Bool `tfsdk:"done"` + // The error result of the operation in case of failure or cancellation. + Error types.Object `tfsdk:"error"` + // Service-specific metadata associated with the operation. It typically + // contains progress information and common metadata such as create time. + // Some services might not provide such metadata. + Metadata types.Object `tfsdk:"metadata"` + // The server-assigned name, which is only unique within the same service + // that originally returns it. If you use the default HTTP mapping, the + // `name` should be a resource name ending with `operations/{unique_id}`. + Name types.String `tfsdk:"name"` + // The normal, successful response of the operation. + Response types.Object `tfsdk:"response"` +} + +func (to *Operation) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Operation) { + if !from.Error.IsNull() && !from.Error.IsUnknown() { + if toError, ok := to.GetError(ctx); ok { + if fromError, ok := from.GetError(ctx); ok { + // Recursively sync the fields of Error + toError.SyncFieldsDuringCreateOrUpdate(ctx, fromError) + to.SetError(ctx, toError) + } + } + } +} + +func (to *Operation) SyncFieldsDuringRead(ctx context.Context, from Operation) { + if !from.Error.IsNull() && !from.Error.IsUnknown() { + if toError, ok := to.GetError(ctx); ok { + if fromError, ok := from.GetError(ctx); ok { + toError.SyncFieldsDuringRead(ctx, fromError) + to.SetError(ctx, toError) + } + } + } +} + +func (m Operation) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["done"] = attrs["done"].SetOptional() + attrs["error"] = attrs["error"].SetOptional() + attrs["metadata"] = attrs["metadata"].SetOptional() + attrs["name"] = attrs["name"].SetOptional() + attrs["response"] = attrs["response"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in Operation. +// 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 (m Operation) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "error": reflect.TypeOf(DatabricksServiceExceptionWithDetailsProto{}), + } +} + +// 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, Operation +// only implements ToObjectValue() and Type(). +func (m Operation) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "done": m.Done, + "error": m.Error, + "metadata": m.Metadata, + "name": m.Name, + "response": m.Response, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m Operation) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "done": types.BoolType, + "error": DatabricksServiceExceptionWithDetailsProto{}.Type(ctx), + "metadata": types.ObjectType{}, + "name": types.StringType, + "response": types.ObjectType{}, + }, + } +} + +// GetError returns the value of the Error field in Operation as +// a DatabricksServiceExceptionWithDetailsProto value. +// If the field is unknown or null, the boolean return value is false. +func (m *Operation) GetError(ctx context.Context) (DatabricksServiceExceptionWithDetailsProto, bool) { + var e DatabricksServiceExceptionWithDetailsProto + if m.Error.IsNull() || m.Error.IsUnknown() { + return e, false + } + var v DatabricksServiceExceptionWithDetailsProto + d := m.Error.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetError sets the value of the Error field in Operation. +func (m *Operation) SetError(ctx context.Context, v DatabricksServiceExceptionWithDetailsProto) { + vs := v.ToObjectValue(ctx) + m.Error = vs +} + +type Project struct { + // The logical size limit for a branch. + BranchLogicalSizeLimitBytes types.Int64 `tfsdk:"branch_logical_size_limit_bytes"` + // The most recent time when any endpoint of this project was active. + ComputeLastActiveTime timetypes.RFC3339 `tfsdk:"compute_last_active_time"` + // A timestamp indicating when the project was created. + CreateTime timetypes.RFC3339 `tfsdk:"create_time"` + + DefaultEndpointSettings types.Object `tfsdk:"default_endpoint_settings"` + // Human-readable project name. + DisplayName types.String `tfsdk:"display_name"` + + EffectiveDefaultEndpointSettings types.Object `tfsdk:"effective_default_endpoint_settings"` + + EffectiveDisplayName types.String `tfsdk:"effective_display_name"` + + EffectiveHistoryRetentionDuration timetypes.GoDuration `tfsdk:"effective_history_retention_duration"` + + EffectivePgVersion types.Int64 `tfsdk:"effective_pg_version"` + + EffectiveSettings types.Object `tfsdk:"effective_settings"` + // The number of seconds to retain the shared history for point in time + // recovery for all branches in this project. + HistoryRetentionDuration timetypes.GoDuration `tfsdk:"history_retention_duration"` + // The resource name of the project. Format: projects/{project_id} + Name types.String `tfsdk:"name"` + // The major Postgres version number. + PgVersion types.Int64 `tfsdk:"pg_version"` + + Settings types.Object `tfsdk:"settings"` + // The current space occupied by the project in storage. Synthetic storage + // size combines the logical data size and Write-Ahead Log (WAL) size for + // all branches in a project. + SyntheticStorageSizeBytes types.Int64 `tfsdk:"synthetic_storage_size_bytes"` + // System generated unique ID for the project. + Uid types.String `tfsdk:"uid"` + // A timestamp indicating when the project was last updated. + UpdateTime timetypes.RFC3339 `tfsdk:"update_time"` +} + +func (to *Project) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from Project) { + if !from.DefaultEndpointSettings.IsUnknown() && !from.DefaultEndpointSettings.IsNull() { + // DefaultEndpointSettings is an input only field and not returned by the service, so we keep the value from the prior state. + to.DefaultEndpointSettings = from.DefaultEndpointSettings + } + if !from.DefaultEndpointSettings.IsNull() && !from.DefaultEndpointSettings.IsUnknown() { + if toDefaultEndpointSettings, ok := to.GetDefaultEndpointSettings(ctx); ok { + if fromDefaultEndpointSettings, ok := from.GetDefaultEndpointSettings(ctx); ok { + // Recursively sync the fields of DefaultEndpointSettings + toDefaultEndpointSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromDefaultEndpointSettings) + to.SetDefaultEndpointSettings(ctx, toDefaultEndpointSettings) + } + } + } + if !from.DisplayName.IsUnknown() && !from.DisplayName.IsNull() { + // DisplayName is an input only field and not returned by the service, so we keep the value from the prior state. + to.DisplayName = from.DisplayName + } + if !from.EffectiveDefaultEndpointSettings.IsNull() && !from.EffectiveDefaultEndpointSettings.IsUnknown() { + if toEffectiveDefaultEndpointSettings, ok := to.GetEffectiveDefaultEndpointSettings(ctx); ok { + if fromEffectiveDefaultEndpointSettings, ok := from.GetEffectiveDefaultEndpointSettings(ctx); ok { + // Recursively sync the fields of EffectiveDefaultEndpointSettings + toEffectiveDefaultEndpointSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromEffectiveDefaultEndpointSettings) + to.SetEffectiveDefaultEndpointSettings(ctx, toEffectiveDefaultEndpointSettings) + } + } + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + // Recursively sync the fields of EffectiveSettings + toEffectiveSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + if !from.HistoryRetentionDuration.IsUnknown() && !from.HistoryRetentionDuration.IsNull() { + // HistoryRetentionDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.HistoryRetentionDuration = from.HistoryRetentionDuration + } + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + // Recursively sync the fields of Settings + toSettings.SyncFieldsDuringCreateOrUpdate(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } +} + +func (to *Project) SyncFieldsDuringRead(ctx context.Context, from Project) { + if !from.DefaultEndpointSettings.IsUnknown() && !from.DefaultEndpointSettings.IsNull() { + // DefaultEndpointSettings is an input only field and not returned by the service, so we keep the value from the prior state. + to.DefaultEndpointSettings = from.DefaultEndpointSettings + } + if !from.DefaultEndpointSettings.IsNull() && !from.DefaultEndpointSettings.IsUnknown() { + if toDefaultEndpointSettings, ok := to.GetDefaultEndpointSettings(ctx); ok { + if fromDefaultEndpointSettings, ok := from.GetDefaultEndpointSettings(ctx); ok { + toDefaultEndpointSettings.SyncFieldsDuringRead(ctx, fromDefaultEndpointSettings) + to.SetDefaultEndpointSettings(ctx, toDefaultEndpointSettings) + } + } + } + if !from.DisplayName.IsUnknown() && !from.DisplayName.IsNull() { + // DisplayName is an input only field and not returned by the service, so we keep the value from the prior state. + to.DisplayName = from.DisplayName + } + if !from.EffectiveDefaultEndpointSettings.IsNull() && !from.EffectiveDefaultEndpointSettings.IsUnknown() { + if toEffectiveDefaultEndpointSettings, ok := to.GetEffectiveDefaultEndpointSettings(ctx); ok { + if fromEffectiveDefaultEndpointSettings, ok := from.GetEffectiveDefaultEndpointSettings(ctx); ok { + toEffectiveDefaultEndpointSettings.SyncFieldsDuringRead(ctx, fromEffectiveDefaultEndpointSettings) + to.SetEffectiveDefaultEndpointSettings(ctx, toEffectiveDefaultEndpointSettings) + } + } + } + if !from.EffectiveSettings.IsNull() && !from.EffectiveSettings.IsUnknown() { + if toEffectiveSettings, ok := to.GetEffectiveSettings(ctx); ok { + if fromEffectiveSettings, ok := from.GetEffectiveSettings(ctx); ok { + toEffectiveSettings.SyncFieldsDuringRead(ctx, fromEffectiveSettings) + to.SetEffectiveSettings(ctx, toEffectiveSettings) + } + } + } + if !from.HistoryRetentionDuration.IsUnknown() && !from.HistoryRetentionDuration.IsNull() { + // HistoryRetentionDuration is an input only field and not returned by the service, so we keep the value from the prior state. + to.HistoryRetentionDuration = from.HistoryRetentionDuration + } + if !from.Settings.IsNull() && !from.Settings.IsUnknown() { + if toSettings, ok := to.GetSettings(ctx); ok { + if fromSettings, ok := from.GetSettings(ctx); ok { + toSettings.SyncFieldsDuringRead(ctx, fromSettings) + to.SetSettings(ctx, toSettings) + } + } + } +} + +func (m Project) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["branch_logical_size_limit_bytes"] = attrs["branch_logical_size_limit_bytes"].SetComputed() + attrs["compute_last_active_time"] = attrs["compute_last_active_time"].SetComputed() + attrs["create_time"] = attrs["create_time"].SetComputed() + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].SetOptional() + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].SetComputed() + attrs["default_endpoint_settings"] = attrs["default_endpoint_settings"].(tfschema.SingleNestedAttributeBuilder).AddPlanModifier(objectplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["display_name"] = attrs["display_name"].SetOptional() + attrs["display_name"] = attrs["display_name"].SetComputed() + attrs["display_name"] = attrs["display_name"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["effective_default_endpoint_settings"] = attrs["effective_default_endpoint_settings"].SetComputed() + attrs["effective_display_name"] = attrs["effective_display_name"].SetComputed() + attrs["effective_history_retention_duration"] = attrs["effective_history_retention_duration"].SetComputed() + attrs["effective_pg_version"] = attrs["effective_pg_version"].SetComputed() + attrs["effective_settings"] = attrs["effective_settings"].SetComputed() + attrs["history_retention_duration"] = attrs["history_retention_duration"].SetOptional() + attrs["history_retention_duration"] = attrs["history_retention_duration"].SetComputed() + attrs["history_retention_duration"] = attrs["history_retention_duration"].(tfschema.StringAttributeBuilder).AddPlanModifier(stringplanmodifier.UseStateForUnknown()).(tfschema.AttributeBuilder) + attrs["name"] = attrs["name"].SetOptional() + attrs["pg_version"] = attrs["pg_version"].SetOptional() + attrs["pg_version"] = attrs["pg_version"].(tfschema.Int64AttributeBuilder).AddPlanModifier(int64planmodifier.RequiresReplace()).(tfschema.AttributeBuilder) + attrs["settings"] = attrs["settings"].SetOptional() + attrs["synthetic_storage_size_bytes"] = attrs["synthetic_storage_size_bytes"].SetComputed() + attrs["uid"] = attrs["uid"].SetComputed() + attrs["update_time"] = attrs["update_time"].SetComputed() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in Project. +// 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 (m Project) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "default_endpoint_settings": reflect.TypeOf(ProjectDefaultEndpointSettings{}), + "effective_default_endpoint_settings": reflect.TypeOf(ProjectDefaultEndpointSettings{}), + "effective_settings": reflect.TypeOf(ProjectSettings{}), + "settings": reflect.TypeOf(ProjectSettings{}), + } +} + +// 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, Project +// only implements ToObjectValue() and Type(). +func (m Project) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "branch_logical_size_limit_bytes": m.BranchLogicalSizeLimitBytes, + "compute_last_active_time": m.ComputeLastActiveTime, + "create_time": m.CreateTime, + "default_endpoint_settings": m.DefaultEndpointSettings, + "display_name": m.DisplayName, + "effective_default_endpoint_settings": m.EffectiveDefaultEndpointSettings, + "effective_display_name": m.EffectiveDisplayName, + "effective_history_retention_duration": m.EffectiveHistoryRetentionDuration, + "effective_pg_version": m.EffectivePgVersion, + "effective_settings": m.EffectiveSettings, + "history_retention_duration": m.HistoryRetentionDuration, + "name": m.Name, + "pg_version": m.PgVersion, + "settings": m.Settings, + "synthetic_storage_size_bytes": m.SyntheticStorageSizeBytes, + "uid": m.Uid, + "update_time": m.UpdateTime, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m Project) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "branch_logical_size_limit_bytes": types.Int64Type, + "compute_last_active_time": timetypes.RFC3339{}.Type(ctx), + "create_time": timetypes.RFC3339{}.Type(ctx), + "default_endpoint_settings": ProjectDefaultEndpointSettings{}.Type(ctx), + "display_name": types.StringType, + "effective_default_endpoint_settings": ProjectDefaultEndpointSettings{}.Type(ctx), + "effective_display_name": types.StringType, + "effective_history_retention_duration": timetypes.GoDuration{}.Type(ctx), + "effective_pg_version": types.Int64Type, + "effective_settings": ProjectSettings{}.Type(ctx), + "history_retention_duration": timetypes.GoDuration{}.Type(ctx), + "name": types.StringType, + "pg_version": types.Int64Type, + "settings": ProjectSettings{}.Type(ctx), + "synthetic_storage_size_bytes": types.Int64Type, + "uid": types.StringType, + "update_time": timetypes.RFC3339{}.Type(ctx), + }, + } +} + +// GetDefaultEndpointSettings returns the value of the DefaultEndpointSettings field in Project as +// a ProjectDefaultEndpointSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project) GetDefaultEndpointSettings(ctx context.Context) (ProjectDefaultEndpointSettings, bool) { + var e ProjectDefaultEndpointSettings + if m.DefaultEndpointSettings.IsNull() || m.DefaultEndpointSettings.IsUnknown() { + return e, false + } + var v ProjectDefaultEndpointSettings + d := m.DefaultEndpointSettings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetDefaultEndpointSettings sets the value of the DefaultEndpointSettings field in Project. +func (m *Project) SetDefaultEndpointSettings(ctx context.Context, v ProjectDefaultEndpointSettings) { + vs := v.ToObjectValue(ctx) + m.DefaultEndpointSettings = vs +} + +// GetEffectiveDefaultEndpointSettings returns the value of the EffectiveDefaultEndpointSettings field in Project as +// a ProjectDefaultEndpointSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project) GetEffectiveDefaultEndpointSettings(ctx context.Context) (ProjectDefaultEndpointSettings, bool) { + var e ProjectDefaultEndpointSettings + if m.EffectiveDefaultEndpointSettings.IsNull() || m.EffectiveDefaultEndpointSettings.IsUnknown() { + return e, false + } + var v ProjectDefaultEndpointSettings + d := m.EffectiveDefaultEndpointSettings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetEffectiveDefaultEndpointSettings sets the value of the EffectiveDefaultEndpointSettings field in Project. +func (m *Project) SetEffectiveDefaultEndpointSettings(ctx context.Context, v ProjectDefaultEndpointSettings) { + vs := v.ToObjectValue(ctx) + m.EffectiveDefaultEndpointSettings = vs +} + +// GetEffectiveSettings returns the value of the EffectiveSettings field in Project as +// a ProjectSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project) GetEffectiveSettings(ctx context.Context) (ProjectSettings, bool) { + var e ProjectSettings + if m.EffectiveSettings.IsNull() || m.EffectiveSettings.IsUnknown() { + return e, false + } + var v ProjectSettings + d := m.EffectiveSettings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetEffectiveSettings sets the value of the EffectiveSettings field in Project. +func (m *Project) SetEffectiveSettings(ctx context.Context, v ProjectSettings) { + vs := v.ToObjectValue(ctx) + m.EffectiveSettings = vs +} + +// GetSettings returns the value of the Settings field in Project as +// a ProjectSettings value. +// If the field is unknown or null, the boolean return value is false. +func (m *Project) GetSettings(ctx context.Context) (ProjectSettings, bool) { + var e ProjectSettings + if m.Settings.IsNull() || m.Settings.IsUnknown() { + return e, false + } + var v ProjectSettings + d := m.Settings.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetSettings sets the value of the Settings field in Project. +func (m *Project) SetSettings(ctx context.Context, v ProjectSettings) { + vs := v.ToObjectValue(ctx) + m.Settings = vs +} + +// A collection of settings for a compute endpoint. +type ProjectDefaultEndpointSettings struct { + // The maximum number of Compute Units. + AutoscalingLimitMaxCu types.Float64 `tfsdk:"autoscaling_limit_max_cu"` + // The minimum number of Compute Units. + AutoscalingLimitMinCu types.Float64 `tfsdk:"autoscaling_limit_min_cu"` + // A raw representation of Postgres settings. + PgSettings types.Map `tfsdk:"pg_settings"` + // A raw representation of PgBouncer settings. + PgbouncerSettings types.Map `tfsdk:"pgbouncer_settings"` + // Duration of inactivity after which the compute endpoint is automatically + // suspended. + SuspendTimeoutDuration timetypes.GoDuration `tfsdk:"suspend_timeout_duration"` +} + +func (to *ProjectDefaultEndpointSettings) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ProjectDefaultEndpointSettings) { +} + +func (to *ProjectDefaultEndpointSettings) SyncFieldsDuringRead(ctx context.Context, from ProjectDefaultEndpointSettings) { +} + +func (m ProjectDefaultEndpointSettings) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["autoscaling_limit_max_cu"] = attrs["autoscaling_limit_max_cu"].SetOptional() + attrs["autoscaling_limit_min_cu"] = attrs["autoscaling_limit_min_cu"].SetOptional() + attrs["pg_settings"] = attrs["pg_settings"].SetOptional() + attrs["pgbouncer_settings"] = attrs["pgbouncer_settings"].SetOptional() + attrs["suspend_timeout_duration"] = attrs["suspend_timeout_duration"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ProjectDefaultEndpointSettings. +// 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 (m ProjectDefaultEndpointSettings) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "pg_settings": reflect.TypeOf(types.String{}), + "pgbouncer_settings": reflect.TypeOf(types.String{}), + } +} + +// 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, ProjectDefaultEndpointSettings +// only implements ToObjectValue() and Type(). +func (m ProjectDefaultEndpointSettings) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "autoscaling_limit_max_cu": m.AutoscalingLimitMaxCu, + "autoscaling_limit_min_cu": m.AutoscalingLimitMinCu, + "pg_settings": m.PgSettings, + "pgbouncer_settings": m.PgbouncerSettings, + "suspend_timeout_duration": m.SuspendTimeoutDuration, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ProjectDefaultEndpointSettings) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "autoscaling_limit_max_cu": types.Float64Type, + "autoscaling_limit_min_cu": types.Float64Type, + "pg_settings": basetypes.MapType{ + ElemType: types.StringType, + }, + "pgbouncer_settings": basetypes.MapType{ + ElemType: types.StringType, + }, + "suspend_timeout_duration": timetypes.GoDuration{}.Type(ctx), + }, + } +} + +// GetPgSettings returns the value of the PgSettings field in ProjectDefaultEndpointSettings as +// a map of string to types.String values. +// If the field is unknown or null, the boolean return value is false. +func (m *ProjectDefaultEndpointSettings) GetPgSettings(ctx context.Context) (map[string]types.String, bool) { + if m.PgSettings.IsNull() || m.PgSettings.IsUnknown() { + return nil, false + } + var v map[string]types.String + d := m.PgSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetPgSettings sets the value of the PgSettings field in ProjectDefaultEndpointSettings. +func (m *ProjectDefaultEndpointSettings) SetPgSettings(ctx context.Context, v map[string]types.String) { + vs := make(map[string]attr.Value, len(v)) + for k, e := range v { + vs[k] = e + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["pg_settings"] + t = t.(attr.TypeWithElementType).ElementType() + m.PgSettings = types.MapValueMust(t, vs) +} + +// GetPgbouncerSettings returns the value of the PgbouncerSettings field in ProjectDefaultEndpointSettings as +// a map of string to types.String values. +// If the field is unknown or null, the boolean return value is false. +func (m *ProjectDefaultEndpointSettings) GetPgbouncerSettings(ctx context.Context) (map[string]types.String, bool) { + if m.PgbouncerSettings.IsNull() || m.PgbouncerSettings.IsUnknown() { + return nil, false + } + var v map[string]types.String + d := m.PgbouncerSettings.ElementsAs(ctx, &v, true) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetPgbouncerSettings sets the value of the PgbouncerSettings field in ProjectDefaultEndpointSettings. +func (m *ProjectDefaultEndpointSettings) SetPgbouncerSettings(ctx context.Context, v map[string]types.String) { + vs := make(map[string]attr.Value, len(v)) + for k, e := range v { + vs[k] = e + } + t := m.Type(ctx).(basetypes.ObjectType).AttrTypes["pgbouncer_settings"] + t = t.(attr.TypeWithElementType).ElementType() + m.PgbouncerSettings = types.MapValueMust(t, vs) +} + +type ProjectOperationMetadata struct { +} + +func (to *ProjectOperationMetadata) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ProjectOperationMetadata) { +} + +func (to *ProjectOperationMetadata) SyncFieldsDuringRead(ctx context.Context, from ProjectOperationMetadata) { +} + +func (m ProjectOperationMetadata) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ProjectOperationMetadata. +// 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 (m ProjectOperationMetadata) 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, ProjectOperationMetadata +// only implements ToObjectValue() and Type(). +func (m ProjectOperationMetadata) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{}) +} + +// Type implements basetypes.ObjectValuable. +func (m ProjectOperationMetadata) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{}, + } +} + +type ProjectSettings struct { + // Sets wal_level=logical for all compute endpoints in this project. All + // active endpoints will be suspended. Once enabled, logical replication + // cannot be disabled. + EnableLogicalReplication types.Bool `tfsdk:"enable_logical_replication"` +} + +func (to *ProjectSettings) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from ProjectSettings) { +} + +func (to *ProjectSettings) SyncFieldsDuringRead(ctx context.Context, from ProjectSettings) { +} + +func (m ProjectSettings) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["enable_logical_replication"] = attrs["enable_logical_replication"].SetOptional() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in ProjectSettings. +// 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 (m ProjectSettings) 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, ProjectSettings +// only implements ToObjectValue() and Type(). +func (m ProjectSettings) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "enable_logical_replication": m.EnableLogicalReplication, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m ProjectSettings) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "enable_logical_replication": types.BoolType, + }, + } +} + +type UpdateBranchRequest struct { + // The Branch to update. + // + // The branch's `name` field is used to identify the branch to update. + // Format: projects/{project_id}/branches/{branch_id} + Branch types.Object `tfsdk:"branch"` + // The resource name of the branch. Format: + // projects/{project_id}/branches/{branch_id} + Name types.String `tfsdk:"-"` + // The list of fields to update. If unspecified, all fields will be updated + // when possible. + UpdateMask types.String `tfsdk:"-"` +} + +func (to *UpdateBranchRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from UpdateBranchRequest) { + if !from.Branch.IsNull() && !from.Branch.IsUnknown() { + if toBranch, ok := to.GetBranch(ctx); ok { + if fromBranch, ok := from.GetBranch(ctx); ok { + // Recursively sync the fields of Branch + toBranch.SyncFieldsDuringCreateOrUpdate(ctx, fromBranch) + to.SetBranch(ctx, toBranch) + } + } + } +} + +func (to *UpdateBranchRequest) SyncFieldsDuringRead(ctx context.Context, from UpdateBranchRequest) { + if !from.Branch.IsNull() && !from.Branch.IsUnknown() { + if toBranch, ok := to.GetBranch(ctx); ok { + if fromBranch, ok := from.GetBranch(ctx); ok { + toBranch.SyncFieldsDuringRead(ctx, fromBranch) + to.SetBranch(ctx, toBranch) + } + } + } +} + +func (m UpdateBranchRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["branch"] = attrs["branch"].SetRequired() + attrs["name"] = attrs["name"].SetRequired() + attrs["update_mask"] = attrs["update_mask"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in UpdateBranchRequest. +// 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 (m UpdateBranchRequest) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "branch": reflect.TypeOf(Branch{}), + } +} + +// 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, UpdateBranchRequest +// only implements ToObjectValue() and Type(). +func (m UpdateBranchRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "branch": m.Branch, + "name": m.Name, + "update_mask": m.UpdateMask, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m UpdateBranchRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "branch": Branch{}.Type(ctx), + "name": types.StringType, + "update_mask": types.StringType, + }, + } +} + +// GetBranch returns the value of the Branch field in UpdateBranchRequest as +// a Branch value. +// If the field is unknown or null, the boolean return value is false. +func (m *UpdateBranchRequest) GetBranch(ctx context.Context) (Branch, bool) { + var e Branch + if m.Branch.IsNull() || m.Branch.IsUnknown() { + return e, false + } + var v Branch + d := m.Branch.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetBranch sets the value of the Branch field in UpdateBranchRequest. +func (m *UpdateBranchRequest) SetBranch(ctx context.Context, v Branch) { + vs := v.ToObjectValue(ctx) + m.Branch = vs +} + +type UpdateEndpointRequest struct { + // The Endpoint to update. + // + // The endpoint's `name` field is used to identify the endpoint to update. + // Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Endpoint types.Object `tfsdk:"endpoint"` + // The resource name of the endpoint. Format: + // projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id} + Name types.String `tfsdk:"-"` + // The list of fields to update. If unspecified, all fields will be updated + // when possible. + UpdateMask types.String `tfsdk:"-"` +} + +func (to *UpdateEndpointRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from UpdateEndpointRequest) { + if !from.Endpoint.IsNull() && !from.Endpoint.IsUnknown() { + if toEndpoint, ok := to.GetEndpoint(ctx); ok { + if fromEndpoint, ok := from.GetEndpoint(ctx); ok { + // Recursively sync the fields of Endpoint + toEndpoint.SyncFieldsDuringCreateOrUpdate(ctx, fromEndpoint) + to.SetEndpoint(ctx, toEndpoint) + } + } + } +} + +func (to *UpdateEndpointRequest) SyncFieldsDuringRead(ctx context.Context, from UpdateEndpointRequest) { + if !from.Endpoint.IsNull() && !from.Endpoint.IsUnknown() { + if toEndpoint, ok := to.GetEndpoint(ctx); ok { + if fromEndpoint, ok := from.GetEndpoint(ctx); ok { + toEndpoint.SyncFieldsDuringRead(ctx, fromEndpoint) + to.SetEndpoint(ctx, toEndpoint) + } + } + } +} + +func (m UpdateEndpointRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["endpoint"] = attrs["endpoint"].SetRequired() + attrs["name"] = attrs["name"].SetRequired() + attrs["update_mask"] = attrs["update_mask"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in UpdateEndpointRequest. +// 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 (m UpdateEndpointRequest) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "endpoint": reflect.TypeOf(Endpoint{}), + } +} + +// 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, UpdateEndpointRequest +// only implements ToObjectValue() and Type(). +func (m UpdateEndpointRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "endpoint": m.Endpoint, + "name": m.Name, + "update_mask": m.UpdateMask, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m UpdateEndpointRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "endpoint": Endpoint{}.Type(ctx), + "name": types.StringType, + "update_mask": types.StringType, + }, + } +} + +// GetEndpoint returns the value of the Endpoint field in UpdateEndpointRequest as +// a Endpoint value. +// If the field is unknown or null, the boolean return value is false. +func (m *UpdateEndpointRequest) GetEndpoint(ctx context.Context) (Endpoint, bool) { + var e Endpoint + if m.Endpoint.IsNull() || m.Endpoint.IsUnknown() { + return e, false + } + var v Endpoint + d := m.Endpoint.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetEndpoint sets the value of the Endpoint field in UpdateEndpointRequest. +func (m *UpdateEndpointRequest) SetEndpoint(ctx context.Context, v Endpoint) { + vs := v.ToObjectValue(ctx) + m.Endpoint = vs +} + +type UpdateProjectRequest struct { + // The resource name of the project. Format: projects/{project_id} + Name types.String `tfsdk:"-"` + // The Project to update. + // + // The project's `name` field is used to identify the project to update. + // Format: projects/{project_id} + Project types.Object `tfsdk:"project"` + // The list of fields to update. If unspecified, all fields will be updated + // when possible. + UpdateMask types.String `tfsdk:"-"` +} + +func (to *UpdateProjectRequest) SyncFieldsDuringCreateOrUpdate(ctx context.Context, from UpdateProjectRequest) { + if !from.Project.IsNull() && !from.Project.IsUnknown() { + if toProject, ok := to.GetProject(ctx); ok { + if fromProject, ok := from.GetProject(ctx); ok { + // Recursively sync the fields of Project + toProject.SyncFieldsDuringCreateOrUpdate(ctx, fromProject) + to.SetProject(ctx, toProject) + } + } + } +} + +func (to *UpdateProjectRequest) SyncFieldsDuringRead(ctx context.Context, from UpdateProjectRequest) { + if !from.Project.IsNull() && !from.Project.IsUnknown() { + if toProject, ok := to.GetProject(ctx); ok { + if fromProject, ok := from.GetProject(ctx); ok { + toProject.SyncFieldsDuringRead(ctx, fromProject) + to.SetProject(ctx, toProject) + } + } + } +} + +func (m UpdateProjectRequest) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder { + attrs["project"] = attrs["project"].SetRequired() + attrs["name"] = attrs["name"].SetRequired() + attrs["update_mask"] = attrs["update_mask"].SetRequired() + + return attrs +} + +// GetComplexFieldTypes returns a map of the types of elements in complex fields in UpdateProjectRequest. +// 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 (m UpdateProjectRequest) GetComplexFieldTypes(ctx context.Context) map[string]reflect.Type { + return map[string]reflect.Type{ + "project": reflect.TypeOf(Project{}), + } +} + +// 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, UpdateProjectRequest +// only implements ToObjectValue() and Type(). +func (m UpdateProjectRequest) ToObjectValue(ctx context.Context) basetypes.ObjectValue { + return types.ObjectValueMust( + m.Type(ctx).(basetypes.ObjectType).AttrTypes, + map[string]attr.Value{ + "name": m.Name, + "project": m.Project, + "update_mask": m.UpdateMask, + }) +} + +// Type implements basetypes.ObjectValuable. +func (m UpdateProjectRequest) Type(ctx context.Context) attr.Type { + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "name": types.StringType, + "project": Project{}.Type(ctx), + "update_mask": types.StringType, + }, + } +} + +// GetProject returns the value of the Project field in UpdateProjectRequest as +// a Project value. +// If the field is unknown or null, the boolean return value is false. +func (m *UpdateProjectRequest) GetProject(ctx context.Context) (Project, bool) { + var e Project + if m.Project.IsNull() || m.Project.IsUnknown() { + return e, false + } + var v Project + d := m.Project.As(ctx, &v, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + }) + if d.HasError() { + panic(pluginfwcommon.DiagToString(d)) + } + return v, true +} + +// SetProject sets the value of the Project field in UpdateProjectRequest. +func (m *UpdateProjectRequest) SetProject(ctx context.Context, v Project) { + vs := v.ToObjectValue(ctx) + m.Project = vs +} diff --git a/internal/service/settings_tf/legacy_model.go b/internal/service/settings_tf/legacy_model.go index cb6eb169ff..e2cb08f3c7 100755 --- a/internal/service/settings_tf/legacy_model.go +++ b/internal/service/settings_tf/legacy_model.go @@ -3153,6 +3153,8 @@ type CustomerFacingNetworkConnectivityConfigAwsPrivateEndpointRule_SdkV2 struct // The full target AWS endpoint service name that connects to the // destination resources of the private endpoint. EndpointService types.String `tfsdk:"endpoint_service"` + + ErrorMessage types.String `tfsdk:"error_message"` // The ID of a network connectivity configuration, which is the parent // resource of this private endpoint rule object. NetworkConnectivityConfigId types.String `tfsdk:"network_connectivity_config_id"` @@ -3211,6 +3213,7 @@ func (m CustomerFacingNetworkConnectivityConfigAwsPrivateEndpointRule_SdkV2) App attrs["domain_names"] = attrs["domain_names"].SetOptional() attrs["enabled"] = attrs["enabled"].SetOptional() attrs["endpoint_service"] = attrs["endpoint_service"].SetOptional() + attrs["error_message"] = attrs["error_message"].SetOptional() attrs["network_connectivity_config_id"] = attrs["network_connectivity_config_id"].SetOptional() attrs["resource_names"] = attrs["resource_names"].SetOptional() attrs["rule_id"] = attrs["rule_id"].SetOptional() @@ -3249,6 +3252,7 @@ func (m CustomerFacingNetworkConnectivityConfigAwsPrivateEndpointRule_SdkV2) ToO "domain_names": m.DomainNames, "enabled": m.Enabled, "endpoint_service": m.EndpointService, + "error_message": m.ErrorMessage, "network_connectivity_config_id": m.NetworkConnectivityConfigId, "resource_names": m.ResourceNames, "rule_id": m.RuleId, @@ -3271,6 +3275,7 @@ func (m CustomerFacingNetworkConnectivityConfigAwsPrivateEndpointRule_SdkV2) Typ }, "enabled": types.BoolType, "endpoint_service": types.StringType, + "error_message": types.StringType, "network_connectivity_config_id": types.StringType, "resource_names": basetypes.ListType{ ElemType: types.StringType, @@ -11950,6 +11955,8 @@ type NccAzurePrivateEndpointRule_SdkV2 struct { DomainNames types.List `tfsdk:"domain_names"` // The name of the Azure private endpoint resource. EndpointName types.String `tfsdk:"endpoint_name"` + + ErrorMessage types.String `tfsdk:"error_message"` // Only used by private endpoints to Azure first-party services. // // The sub-resource type (group ID) of the target resource. Note that to @@ -11992,6 +11999,7 @@ func (m NccAzurePrivateEndpointRule_SdkV2) ApplySchemaCustomizations(attrs map[s attrs["deactivated_at"] = attrs["deactivated_at"].SetOptional() attrs["domain_names"] = attrs["domain_names"].SetOptional() attrs["endpoint_name"] = attrs["endpoint_name"].SetOptional() + attrs["error_message"] = attrs["error_message"].SetOptional() attrs["group_id"] = attrs["group_id"].SetOptional() attrs["network_connectivity_config_id"] = attrs["network_connectivity_config_id"].SetOptional() attrs["resource_id"] = attrs["resource_id"].SetOptional() @@ -12027,6 +12035,7 @@ func (m NccAzurePrivateEndpointRule_SdkV2) ToObjectValue(ctx context.Context) ba "deactivated_at": m.DeactivatedAt, "domain_names": m.DomainNames, "endpoint_name": m.EndpointName, + "error_message": m.ErrorMessage, "group_id": m.GroupId, "network_connectivity_config_id": m.NetworkConnectivityConfigId, "resource_id": m.ResourceId, @@ -12047,6 +12056,7 @@ func (m NccAzurePrivateEndpointRule_SdkV2) Type(ctx context.Context) attr.Type { ElemType: types.StringType, }, "endpoint_name": types.StringType, + "error_message": types.StringType, "group_id": types.StringType, "network_connectivity_config_id": types.StringType, "resource_id": types.StringType, diff --git a/internal/service/settings_tf/model.go b/internal/service/settings_tf/model.go index 65e691c57a..3018598182 100755 --- a/internal/service/settings_tf/model.go +++ b/internal/service/settings_tf/model.go @@ -3060,6 +3060,8 @@ type CustomerFacingNetworkConnectivityConfigAwsPrivateEndpointRule struct { // The full target AWS endpoint service name that connects to the // destination resources of the private endpoint. EndpointService types.String `tfsdk:"endpoint_service"` + + ErrorMessage types.String `tfsdk:"error_message"` // The ID of a network connectivity configuration, which is the parent // resource of this private endpoint rule object. NetworkConnectivityConfigId types.String `tfsdk:"network_connectivity_config_id"` @@ -3118,6 +3120,7 @@ func (m CustomerFacingNetworkConnectivityConfigAwsPrivateEndpointRule) ApplySche attrs["domain_names"] = attrs["domain_names"].SetOptional() attrs["enabled"] = attrs["enabled"].SetOptional() attrs["endpoint_service"] = attrs["endpoint_service"].SetOptional() + attrs["error_message"] = attrs["error_message"].SetOptional() attrs["network_connectivity_config_id"] = attrs["network_connectivity_config_id"].SetOptional() attrs["resource_names"] = attrs["resource_names"].SetOptional() attrs["rule_id"] = attrs["rule_id"].SetOptional() @@ -3156,6 +3159,7 @@ func (m CustomerFacingNetworkConnectivityConfigAwsPrivateEndpointRule) ToObjectV "domain_names": m.DomainNames, "enabled": m.Enabled, "endpoint_service": m.EndpointService, + "error_message": m.ErrorMessage, "network_connectivity_config_id": m.NetworkConnectivityConfigId, "resource_names": m.ResourceNames, "rule_id": m.RuleId, @@ -3178,6 +3182,7 @@ func (m CustomerFacingNetworkConnectivityConfigAwsPrivateEndpointRule) Type(ctx }, "enabled": types.BoolType, "endpoint_service": types.StringType, + "error_message": types.StringType, "network_connectivity_config_id": types.StringType, "resource_names": basetypes.ListType{ ElemType: types.StringType, @@ -11773,6 +11778,8 @@ type NccAzurePrivateEndpointRule struct { DomainNames types.List `tfsdk:"domain_names"` // The name of the Azure private endpoint resource. EndpointName types.String `tfsdk:"endpoint_name"` + + ErrorMessage types.String `tfsdk:"error_message"` // Only used by private endpoints to Azure first-party services. // // The sub-resource type (group ID) of the target resource. Note that to @@ -11815,6 +11822,7 @@ func (m NccAzurePrivateEndpointRule) ApplySchemaCustomizations(attrs map[string] attrs["deactivated_at"] = attrs["deactivated_at"].SetOptional() attrs["domain_names"] = attrs["domain_names"].SetOptional() attrs["endpoint_name"] = attrs["endpoint_name"].SetOptional() + attrs["error_message"] = attrs["error_message"].SetOptional() attrs["group_id"] = attrs["group_id"].SetOptional() attrs["network_connectivity_config_id"] = attrs["network_connectivity_config_id"].SetOptional() attrs["resource_id"] = attrs["resource_id"].SetOptional() @@ -11850,6 +11858,7 @@ func (m NccAzurePrivateEndpointRule) ToObjectValue(ctx context.Context) basetype "deactivated_at": m.DeactivatedAt, "domain_names": m.DomainNames, "endpoint_name": m.EndpointName, + "error_message": m.ErrorMessage, "group_id": m.GroupId, "network_connectivity_config_id": m.NetworkConnectivityConfigId, "resource_id": m.ResourceId, @@ -11870,6 +11879,7 @@ func (m NccAzurePrivateEndpointRule) Type(ctx context.Context) attr.Type { ElemType: types.StringType, }, "endpoint_name": types.StringType, + "error_message": types.StringType, "group_id": types.StringType, "network_connectivity_config_id": types.StringType, "resource_id": types.StringType, diff --git a/internal/service/vectorsearch_tf/legacy_model.go b/internal/service/vectorsearch_tf/legacy_model.go index de44c59efc..0b66ed298a 100755 --- a/internal/service/vectorsearch_tf/legacy_model.go +++ b/internal/service/vectorsearch_tf/legacy_model.go @@ -2695,8 +2695,7 @@ func (m MiniVectorIndex_SdkV2) Type(ctx context.Context) attr.Type { } type PatchEndpointBudgetPolicyRequest_SdkV2 struct { - // The budget policy id to be applied (hima-sheth) TODO: remove this once - // we've migrated to usage policies + // The budget policy id to be applied BudgetPolicyId types.String `tfsdk:"budget_policy_id"` // Name of the vector search endpoint EndpointName types.String `tfsdk:"-"` diff --git a/internal/service/vectorsearch_tf/model.go b/internal/service/vectorsearch_tf/model.go index 423b47741e..a354b2f14e 100755 --- a/internal/service/vectorsearch_tf/model.go +++ b/internal/service/vectorsearch_tf/model.go @@ -2670,8 +2670,7 @@ func (m MiniVectorIndex) Type(ctx context.Context) attr.Type { } type PatchEndpointBudgetPolicyRequest struct { - // The budget policy id to be applied (hima-sheth) TODO: remove this once - // we've migrated to usage policies + // The budget policy id to be applied BudgetPolicyId types.String `tfsdk:"budget_policy_id"` // Name of the vector search endpoint EndpointName types.String `tfsdk:"-"`