# Copyright 2024 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
name: 'Stream'
description: |
  A resource representing streaming data from a source to a destination.
references:
  guides:
    'Official Documentation': 'https://cloud.google.com/datastream/docs/create-a-stream'
  api: 'https://cloud.google.com/datastream/docs/reference/rest/v1/projects.locations.streams'
docs:
id_format: 'projects/{{project}}/locations/{{location}}/streams/{{stream_id}}'
base_url: 'projects/{{project}}/locations/{{location}}/streams'
self_link: 'projects/{{project}}/locations/{{location}}/streams/{{stream_id}}'
create_url: 'projects/{{project}}/locations/{{location}}/streams?streamId={{stream_id}}&force={{create_without_validation}}'
update_verb: 'PATCH'
update_mask: true
import_format:
  - 'projects/{{project}}/locations/{{location}}/streams/{{stream_id}}'
timeouts:
  insert_minutes: 20
  update_minutes: 20
  delete_minutes: 20
async:
  actions: ['create', 'delete', 'update']
  type: 'OpAsync'
  operation:
    base_url: '{{op_id}}'
  result:
    resource_inside_response: true
custom_code:
  constants: 'templates/terraform/constants/datastream_stream.go.tmpl'
  encoder: 'templates/terraform/encoders/datastream_stream.go.tmpl'
  post_create: 'templates/terraform/post_create/datastream_stream.go.tmpl'
  pre_update: 'templates/terraform/pre_update/datastream_stream.go.tmpl'
  post_update: 'templates/terraform/post_update/datastream_stream.go.tmpl'
  post_import: 'templates/terraform/post_import/datastream_stream.go.tmpl'
custom_diff:
  - 'resourceDatastreamStreamCustomDiff'
examples:
  - name: 'datastream_stream_basic'
    primary_resource_id: 'default'
    vars:
      stream_id: 'my-stream'
      private_connection_id: 'my-connection'
      network_name: 'my-network'
      source_connection_profile_id: 'source-profile'
      database_instance_name: 'my-instance'
      deletion_protection: 'true'
      bucket_name: 'my-bucket'
      destination_connection_profile_id: 'destination-profile'
    test_vars_overrides:
      'deletion_protection': 'false'
    oics_vars_overrides:
      'deletion_protection': 'false'
    external_providers: ["random", "time"]
    exclude_docs: true
      # Random provider
    skip_vcr: true
  - name: 'datastream_stream_full'
    primary_resource_id: 'default'
    vars:
      stream_id: 'my-stream'
      private_connection_id: 'my-connection'
      network_name: 'my-network'
      source_connection_profile_id: 'source-profile'
      database_instance_name: 'my-instance'
      deletion_protection: 'true'
      bucket_name: 'my-bucket'
      destination_connection_profile_id: 'destination-profile'
      stream_cmek: 'kms-name'
    test_vars_overrides:
      'deletion_protection': 'false'
      'stream_cmek': 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name'
    oics_vars_overrides:
      'deletion_protection': 'false'
    external_providers: ["random", "time"]
      # Random provider
    skip_vcr: true
  - name: 'datastream_stream_postgresql'
    primary_resource_id: 'default'
    vars:
      stream_id: 'my-stream'
      source_connection_profile_id: 'source-profile'
      destination_connection_profile_id: 'destination-profile'
    exclude_test: true
  - name: 'datastream_stream_oracle'
    primary_resource_id: 'default'
    vars:
      stream_id: 'my-stream'
      source_connection_profile_id: 'source-profile'
      destination_connection_profile_id: 'destination-profile'
    exclude_test: true
  - name: 'datastream_stream_sql_server'
    primary_resource_id: 'default'
    vars:
      database_name: 'db'
      database_password: 'password'
      database_user: 'user'
      deletion_protection: 'true'
      destination_connection_profile_id: 'destination-profile'
      source_connection_profile_id: 'source-profile'
      sql_server_name: 'sql-server'
      sql_server_root_password: 'root-password'
      stream_id: 'stream'
    test_vars_overrides:
      'deletion_protection': 'false'
    exclude_test: true
  - name: 'datastream_stream_sql_server_change_tables'
    primary_resource_id: 'default'
    vars:
      database_name: 'db'
      database_password: 'password'
      database_user: 'user'
      deletion_protection: 'true'
      destination_connection_profile_id: 'destination-profile'
      source_connection_profile_id: 'source-profile'
      sql_server_name: 'sql-server'
      sql_server_root_password: 'root-password'
      stream_id: 'stream'
    test_vars_overrides:
      'deletion_protection': 'false'
    # Requires SQLServer Configuration
    exclude_test: true
  - name: 'datastream_stream_mysql_gtid'
    primary_resource_id: 'default'
    vars:
      database_name: 'db'
      database_password: 'password'
      database_user: 'user'
      deletion_protection: 'true'
      destination_connection_profile_id: 'destination-profile'
      source_connection_profile_id: 'source-profile'
      mysql_name: 'mysql'
      mysql_root_password: 'root-password'
      stream_id: 'stream'
    test_vars_overrides:
      'deletion_protection': 'false'
    # Requires MySQL Configuration
    exclude_test: true
  - name: 'datastream_stream_postgresql_bigquery_dataset_id'
    primary_resource_id: 'default'
    vars:
      dataset_id: 'postgres'
      stream_id: 'postgres-bigquery'
      dest_connection_profile_id: 'dest-profile'
      instance_name: 'instance-name'
      sql_user_name: 'my-user'
      source_connection_profile_id: 'source-profile'
    external_providers: ["random", "time"]
    # Random provider
    skip_vcr: true
  - name: 'datastream_stream_bigquery'
    primary_resource_id: 'default'
    vars:
      stream_id: 'my-stream'
      private_connection_id: 'my-connection'
      network_name: 'my-network'
      source_connection_profile_id: 'source-profile'
      database_instance_name: 'my-instance'
      deletion_protection: 'true'
      destination_connection_profile_id: 'destination-profile'
      bigquery_destination_table_kms_key_name: 'bigquery-kms-name'
    test_vars_overrides:
      'deletion_protection': 'false'
      'bigquery_destination_table_kms_key_name': 'acctest.BootstrapKMSKeyInLocation(t, "us-central1").CryptoKey.Name'
    oics_vars_overrides:
      'deletion_protection': 'false'
    external_providers: ["random", "time"]
      # Random provider
    skip_vcr: true
  - name: 'datastream_stream_bigquery_append_only'
    primary_resource_id: 'default'
    vars:
      stream_id: 'my-stream'
      private_connection_id: 'my-connection'
      network_name: 'my-network'
      source_connection_profile_id: 'source-profile'
      database_instance_name: 'my-instance'
      deletion_protection: 'true'
      destination_connection_profile_id: 'destination-profile'
    test_vars_overrides:
      'deletion_protection': 'false'
    oics_vars_overrides:
      'deletion_protection': 'false'
    external_providers: ["random", "time"]
      # Random provider
    skip_vcr: true
  - name: 'datastream_stream_bigquery_blmt'
    primary_resource_id: 'default'
    vars:
      stream_id: 'blmt-stream'
      database_instance_name: 'blmt-instance'
      deletion_protection: 'true'
      source_connection_profile_id: 'blmt-source-profile'
      destination_connection_profile_id: 'blmt-destination-profile'
      blmt_bucket_name: 'blmt-bucket'
      blmt_connection_id: 'blmt-connection'
    test_vars_overrides:
      'deletion_protection': 'false'
    external_providers: ["random"]
    skip_vcr: true
    # Involves complex dependency creation, which makes it impractical in this context
    exclude_test: true
  - name: 'datastream_stream_salesforce'
    primary_resource_id: 'default'
    vars:
      source_connection_profile_id: 'source-profile'
      destination_connection_profile_id: 'destination-profile'
    exclude_test: true
virtual_fields:
  - name: 'desired_state'
    description: |
      Desired state of the Stream. Set this field to `RUNNING` to start the stream,
      `NOT_STARTED` to create the stream without starting and `PAUSED` to pause
      the stream from a `RUNNING` state.
      Possible values: NOT_STARTED, RUNNING, PAUSED. Default: NOT_STARTED
    type: String
    default_value: "NOT_STARTED"
parameters:
  - name: 'streamId'
    type: String
    description: |-
      The stream identifier.
    url_param_only: true
    required: true
    immutable: true
  - name: 'create_without_validation'
    type: Boolean
    description: |-
      Create the stream without validating it.
    url_param_only: true
    required: false
    immutable: true
    default_value: false
  - name: 'location'
    type: String
    description: |
      The name of the location this stream is located in.
    url_param_only: true
    required: true
    immutable: true
properties:
  - name: 'name'
    type: String
    description: The stream's name.
    output: true
  - name: 'labels'
    type: KeyValueLabels
    description: Labels.
  - name: 'displayName'
    type: String
    description: Display name.
    required: true
  - name: 'sourceConfig'
    type: NestedObject
    description: |
      Source connection profile configuration.
    required: true
    properties:
      - name: 'sourceConnectionProfile'
        type: String
        description: |
          Source connection profile resource. Format: projects/{project}/locations/{location}/connectionProfiles/{name}
        required: true
        immutable: true
        diff_suppress_func: 'tpgresource.ProjectNumberDiffSuppress'
      - name: 'mysqlSourceConfig'
        type: NestedObject
        description: |
          MySQL data source configuration.
        send_empty_value: true
        allow_empty_object: true
        exactly_one_of:
          - 'source_config.0.mysql_source_config'
          - 'source_config.0.oracle_source_config'
          - 'source_config.0.postgresql_source_config'
          - 'source_config.0.sql_server_source_config'
          - 'source_config.0.salesforce_source_config'
        properties:
          - name: 'includeObjects'
            type: NestedObject
            description: |
              MySQL objects to retrieve from the source.
            properties:
              - name: 'mysqlDatabases'
                type: Array
                description: |
                  MySQL databases on the server
                required: true
                item_type:
                  description: |
                    MySQL database.
                  type: NestedObject
                  properties:
                    - name: 'database'
                      type: String
                      description: |
                        Database name.
                      required: true
                    - name: 'mysqlTables'
                      type: Array
                      description: |
                        Tables in the database.
                      item_type:
                        description: |
                          MySQL table.
                        type: NestedObject
                        properties:
                          - name: 'table'
                            type: String
                            description: |
                              Table name.
                            required: true
                          - name: 'mysqlColumns'
                            type: Array
                            description: |
                              MySQL columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                            item_type:
                              description: |
                                MySQL Column.
                              type: NestedObject
                              properties:
                                - name: 'column'
                                  type: String
                                  description: |
                                    Column name.
                                - name: 'dataType'
                                  type: String
                                  description: |
                                    The MySQL data type. Full data types list can be found here:
                                    https://dev.mysql.com/doc/refman/8.0/en/data-types.html
                                - name: 'length'
                                  type: Integer
                                  description: |
                                    Column length.
                                  output: true
                                - name: 'collation'
                                  type: String
                                  description: |
                                    Column collation.
                                - name: 'primaryKey'
                                  type: Boolean
                                  description: |
                                    Whether or not the column represents a primary key.
                                - name: 'nullable'
                                  type: Boolean
                                  description: |
                                    Whether or not the column can accept a null value.
                                - name: 'ordinalPosition'
                                  type: Integer
                                  description: |
                                    The ordinal position of the column in the table.
                            min_size: 1
                      min_size: 1
                min_size: 1
          - name: 'excludeObjects'
            type: NestedObject
            description: |
              MySQL objects to exclude from the stream.
            properties:
              - name: 'mysqlDatabases'
                type: Array
                description: |
                  MySQL databases on the server
                required: true
                item_type:
                  description: |
                    MySQL database.
                  type: NestedObject
                  properties:
                    - name: 'database'
                      type: String
                      description: |
                        Database name.
                      required: true
                    - name: 'mysqlTables'
                      type: Array
                      description: |
                        Tables in the database.
                      item_type:
                        description: |
                          MySQL table.
                        type: NestedObject
                        properties:
                          - name: 'table'
                            type: String
                            description: |
                              Table name.
                            required: true
                          - name: 'mysqlColumns'
                            type: Array
                            description: |
                              MySQL columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                            item_type:
                              description: |
                                MySQL Column.
                              type: NestedObject
                              properties:
                                - name: 'column'
                                  type: String
                                  description: |
                                    Column name.
                                - name: 'dataType'
                                  type: String
                                  description: |
                                    The MySQL data type. Full data types list can be found here:
                                    https://dev.mysql.com/doc/refman/8.0/en/data-types.html
                                - name: 'length'
                                  type: Integer
                                  description: |
                                    Column length.
                                  output: true
                                - name: 'collation'
                                  type: String
                                  description: |
                                    Column collation.
                                - name: 'primaryKey'
                                  type: Boolean
                                  description: |
                                    Whether or not the column represents a primary key.
                                - name: 'nullable'
                                  type: Boolean
                                  description: |
                                    Whether or not the column can accept a null value.
                                - name: 'ordinalPosition'
                                  type: Integer
                                  description: |
                                    The ordinal position of the column in the table.
                            min_size: 1
                      min_size: 1
                min_size: 1
          - name: 'maxConcurrentCdcTasks'
            type: Integer
            description: |
              Maximum number of concurrent CDC tasks. The number should be non negative.
              If not set (or set to 0), the system's default value will be used.
            default_from_api: true
            send_empty_value: true
            validation:
              function: 'validation.IntAtLeast(0)'
          - name: 'maxConcurrentBackfillTasks'
            type: Integer
            description: |
              Maximum number of concurrent backfill tasks. The number should be non negative.
              If not set (or set to 0), the system's default value will be used.
            default_from_api: true
            send_empty_value: true
            validation:
              function: 'validation.IntAtLeast(0)'
          - name: 'binaryLogPosition'
            type: NestedObject
            allow_empty_object: true
            send_empty_value: true
            conflicts:
              - source_config.0.mysql_source_config.gtid
            description: |
              CDC reader reads from binary logs replication cdc method.
            properties: []
          - name: 'gtid'
            type: NestedObject
            allow_empty_object: true
            send_empty_value: true
            conflicts:
              - source_config.0.mysql_source_config.binaryLogPosition
            description: |
              CDC reader reads from gtid based replication.
            properties: []
      - name: 'oracleSourceConfig'
        type: NestedObject
        description: |
          MySQL data source configuration.
        send_empty_value: true
        allow_empty_object: true
        exactly_one_of:
          - 'source_config.0.mysql_source_config'
          - 'source_config.0.oracle_source_config'
          - 'source_config.0.postgresql_source_config'
          - 'source_config.0.sql_server_source_config'
          - 'source_config.0.salesforce_source_config'
        properties:
          - name: 'includeObjects'
            type: NestedObject
            description: |
              Oracle objects to retrieve from the source.
            properties:
              - name: 'oracleSchemas'
                type: Array
                description: |
                  Oracle schemas/databases in the database server
                required: true
                item_type:
                  description: |
                    MySQL database.
                  type: NestedObject
                  properties:
                    - name: 'schema'
                      type: String
                      description: |
                        Schema name.
                      required: true
                    - name: 'oracleTables'
                      type: Array
                      description: |
                        Tables in the database.
                      item_type:
                        description: |
                          Oracle table.
                        type: NestedObject
                        properties:
                          - name: 'table'
                            type: String
                            description: |
                              Table name.
                            required: true
                          - name: 'oracleColumns'
                            type: Array
                            description: |
                              Oracle columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                            item_type:
                              description: |
                                Oracle Column.
                              type: NestedObject
                              properties:
                                - name: 'column'
                                  type: String
                                  description: |
                                    Column name.
                                - name: 'dataType'
                                  type: String
                                  description: |
                                    The Oracle data type. Full data types list can be found here:
                                    https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html
                                - name: 'length'
                                  type: Integer
                                  description: |
                                    Column length.
                                  output: true
                                - name: 'precision'
                                  type: Integer
                                  description: |
                                    Column precision.
                                  output: true
                                - name: 'scale'
                                  type: Integer
                                  description: |
                                    Column scale.
                                  output: true
                                - name: 'encoding'
                                  type: String
                                  description: |
                                    Column encoding.
                                  output: true
                                - name: 'primaryKey'
                                  type: Boolean
                                  description: |
                                    Whether or not the column represents a primary key.
                                  output: true
                                - name: 'nullable'
                                  type: Boolean
                                  description: |
                                    Whether or not the column can accept a null value.
                                  output: true
                                - name: 'ordinalPosition'
                                  type: Integer
                                  description: |
                                    The ordinal position of the column in the table.
                                  output: true
                            min_size: 1
                      min_size: 1
                min_size: 1
          - name: 'excludeObjects'
            type: NestedObject
            description: |
              Oracle objects to exclude from the stream.
            properties:
              - name: 'oracleSchemas'
                type: Array
                description: |
                  Oracle schemas/databases in the database server
                required: true
                item_type:
                  description: |
                    MySQL database.
                  type: NestedObject
                  properties:
                    - name: 'schema'
                      type: String
                      description: |
                        Schema name.
                      required: true
                    - name: 'oracleTables'
                      type: Array
                      description: |
                        Tables in the database.
                      item_type:
                        description: |
                          Oracle table.
                        type: NestedObject
                        properties:
                          - name: 'table'
                            type: String
                            description: |
                              Table name.
                            required: true
                          - name: 'oracleColumns'
                            type: Array
                            description: |
                              Oracle columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                            item_type:
                              description: |
                                Oracle Column.
                              type: NestedObject
                              properties:
                                - name: 'column'
                                  type: String
                                  description: |
                                    Column name.
                                - name: 'dataType'
                                  type: String
                                  description: |
                                    The Oracle data type. Full data types list can be found here:
                                    https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html
                                - name: 'length'
                                  type: Integer
                                  description: |
                                    Column length.
                                  output: true
                                - name: 'precision'
                                  type: Integer
                                  description: |
                                    Column precision.
                                  output: true
                                - name: 'scale'
                                  type: Integer
                                  description: |
                                    Column scale.
                                  output: true
                                - name: 'encoding'
                                  type: String
                                  description: |
                                    Column encoding.
                                  output: true
                                - name: 'primaryKey'
                                  type: Boolean
                                  description: |
                                    Whether or not the column represents a primary key.
                                  output: true
                                - name: 'nullable'
                                  type: Boolean
                                  description: |
                                    Whether or not the column can accept a null value.
                                  output: true
                                - name: 'ordinalPosition'
                                  type: Integer
                                  description: |
                                    The ordinal position of the column in the table.
                                  output: true
                            min_size: 1
                      min_size: 1
                min_size: 1
          - name: 'maxConcurrentCdcTasks'
            type: Integer
            description: |
              Maximum number of concurrent CDC tasks. The number should be non negative.
              If not set (or set to 0), the system's default value will be used.
            default_from_api: true
            send_empty_value: true
            validation:
              function: 'validation.IntAtLeast(0)'
          - name: 'maxConcurrentBackfillTasks'
            type: Integer
            description: |
              Maximum number of concurrent backfill tasks. The number should be non negative.
              If not set (or set to 0), the system's default value will be used.
            default_from_api: true
            send_empty_value: true
            validation:
              function: 'validation.IntAtLeast(0)'
          - name: 'dropLargeObjects'
            type: NestedObject
            description: |
              Configuration to drop large object values.
            send_empty_value: true
            allow_empty_object: true
            properties:
              []
          - name: 'streamLargeObjects'
            type: NestedObject
            description: |
              Configuration to drop large object values.
            send_empty_value: true
            allow_empty_object: true
            properties:
              []
      - name: 'postgresqlSourceConfig'
        type: NestedObject
        description: |
          PostgreSQL data source configuration.
        send_empty_value: true
        allow_empty_object: true
        exactly_one_of:
          - 'source_config.0.mysql_source_config'
          - 'source_config.0.oracle_source_config'
          - 'source_config.0.postgresql_source_config'
          - 'source_config.0.sql_server_source_config'
          - 'source_config.0.salesforce_source_config'
        properties:
          - name: 'includeObjects'
            type: NestedObject
            description: |
              PostgreSQL objects to retrieve from the source.
            properties:
              - name: 'postgresqlSchemas'
                type: Array
                description: |
                  PostgreSQL schemas on the server
                required: true
                item_type:
                  description: |
                    PostgreSQL schema.
                  type: NestedObject
                  properties:
                    - name: 'schema'
                      type: String
                      description: |
                        Database name.
                      required: true
                    - name: 'postgresqlTables'
                      type: Array
                      description: |
                        Tables in the schema.
                      item_type:
                        description: |
                          PostgreSQL table.
                        type: NestedObject
                        properties:
                          - name: 'table'
                            type: String
                            description: |
                              Table name.
                            required: true
                          - name: 'postgresqlColumns'
                            type: Array
                            description: |
                              PostgreSQL columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                            item_type:
                              description: |
                                PostgreSQL Column.
                              type: NestedObject
                              properties:
                                - name: 'column'
                                  type: String
                                  description: |
                                    Column name.
                                - name: 'dataType'
                                  type: String
                                  description: |
                                    The PostgreSQL data type. Full data types list can be found here:
                                    https://www.postgresql.org/docs/current/datatype.html
                                - name: 'length'
                                  type: Integer
                                  description: |
                                    Column length.
                                  output: true
                                - name: 'precision'
                                  type: Integer
                                  description: |
                                    Column precision.
                                  output: true
                                - name: 'scale'
                                  type: Integer
                                  description: |
                                    Column scale.
                                  output: true
                                - name: 'primaryKey'
                                  type: Boolean
                                  description: |
                                    Whether or not the column represents a primary key.
                                - name: 'nullable'
                                  type: Boolean
                                  description: |
                                    Whether or not the column can accept a null value.
                                - name: 'ordinalPosition'
                                  type: Integer
                                  description: |
                                    The ordinal position of the column in the table.
                            min_size: 1
                      min_size: 1
                min_size: 1
          - name: 'excludeObjects'
            type: NestedObject
            description: |
              PostgreSQL objects to exclude from the stream.
            properties:
              - name: 'postgresqlSchemas'
                type: Array
                description: |
                  PostgreSQL schemas on the server
                required: true
                item_type:
                  description: |
                    PostgreSQL schema.
                  type: NestedObject
                  properties:
                    - name: 'schema'
                      type: String
                      description: |
                        Database name.
                      required: true
                    - name: 'postgresqlTables'
                      type: Array
                      description: |
                        Tables in the schema.
                      item_type:
                        description: |
                          PostgreSQL table.
                        type: NestedObject
                        properties:
                          - name: 'table'
                            type: String
                            description: |
                              Table name.
                            required: true
                          - name: 'postgresqlColumns'
                            type: Array
                            description: |
                              PostgreSQL columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                            item_type:
                              description: |
                                PostgreSQL Column.
                              type: NestedObject
                              properties:
                                - name: 'column'
                                  type: String
                                  description: |
                                    Column name.
                                - name: 'dataType'
                                  type: String
                                  description: |
                                    The PostgreSQL data type. Full data types list can be found here:
                                    https://www.postgresql.org/docs/current/datatype.html
                                - name: 'length'
                                  type: Integer
                                  description: |
                                    Column length.
                                  output: true
                                - name: 'precision'
                                  type: Integer
                                  description: |
                                    Column precision.
                                  output: true
                                - name: 'scale'
                                  type: Integer
                                  description: |
                                    Column scale.
                                  output: true
                                - name: 'primaryKey'
                                  type: Boolean
                                  description: |
                                    Whether or not the column represents a primary key.
                                - name: 'nullable'
                                  type: Boolean
                                  description: |
                                    Whether or not the column can accept a null value.
                                - name: 'ordinalPosition'
                                  type: Integer
                                  description: |
                                    The ordinal position of the column in the table.
                            min_size: 1
                      min_size: 1
                min_size: 1
          - name: 'replicationSlot'
            type: String
            description: |
              The name of the logical replication slot that's configured with
              the pgoutput plugin.
            required: true
          - name: 'publication'
            type: String
            description: |
              The name of the publication that includes the set of all tables
              that are defined in the stream's include_objects.
            required: true
          - name: 'maxConcurrentBackfillTasks'
            type: Integer
            description: |
              Maximum number of concurrent backfill tasks. The number should be non
              negative. If not set (or set to 0), the system's default value will be used.
            default_from_api: true
            send_empty_value: true
            validation:
              function: 'validation.IntAtLeast(0)'
      - name: 'sqlServerSourceConfig'
        type: NestedObject
        description: |
          SQL Server data source configuration.
        send_empty_value: true
        allow_empty_object: true
        exactly_one_of:
          - 'source_config.0.mysql_source_config'
          - 'source_config.0.oracle_source_config'
          - 'source_config.0.postgresql_source_config'
          - 'source_config.0.sql_server_source_config'
          - 'source_config.0.salesforce_source_config'
        properties:
          - name: 'includeObjects'
            type: NestedObject
            description: |
              SQL Server objects to retrieve from the source.
            properties:
              - name: 'schemas'
                type: Array
                description: |
                  SQL Server schemas/databases in the database server
                required: true
                item_type:
                  description: |
                    SQL Server database.
                  type: NestedObject
                  properties:
                    - name: 'schema'
                      type: String
                      description: |
                        Schema name.
                      required: true
                    - name: 'tables'
                      type: Array
                      description: |
                        Tables in the database.
                      item_type:
                        description: |
                          SQL Server table.
                        type: NestedObject
                        properties:
                          - name: 'table'
                            type: String
                            description: |
                              Table name.
                            required: true
                          - name: 'columns'
                            type: Array
                            description: |
                              SQL Server columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                            item_type:
                              description: |
                                SQL Server Column.
                              type: NestedObject
                              properties:
                                - name: 'column'
                                  type: String
                                  description: |
                                    Column name.
                                - name: 'dataType'
                                  type: String
                                  description: |
                                    The SQL Server data type. Full data types list can be found here:
                                    https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver16
                                - name: 'length'
                                  type: Integer
                                  description: |
                                    Column length.
                                  output: true
                                - name: 'precision'
                                  type: Integer
                                  description: |
                                    Column precision.
                                  output: true
                                - name: 'scale'
                                  type: Integer
                                  description: |
                                    Column scale.
                                  output: true
                                - name: 'primaryKey'
                                  type: Boolean
                                  description: |
                                    Whether or not the column represents a primary key.
                                  output: true
                                - name: 'nullable'
                                  type: Boolean
                                  description: |
                                    Whether or not the column can accept a null value.
                                  output: true
                                - name: 'ordinalPosition'
                                  type: Integer
                                  description: |
                                    The ordinal position of the column in the table.
                                  output: true
                            min_size: 1
                      min_size: 1
                min_size: 1
          - name: 'excludeObjects'
            type: NestedObject
            description: |
              SQL Server objects to exclude from the stream.
            properties:
              - name: 'schemas'
                type: Array
                description: |
                  SQL Server schemas/databases in the database server
                required: true
                item_type:
                  description: |
                    SQL Server database.
                  type: NestedObject
                  properties:
                    - name: 'schema'
                      type: String
                      description: |
                        Schema name.
                      required: true
                    - name: 'tables'
                      type: Array
                      description: |
                        Tables in the database.
                      item_type:
                        description: |
                          SQL Server table.
                        type: NestedObject
                        properties:
                          - name: 'table'
                            type: String
                            description: |
                              Table name.
                            required: true
                          - name: 'columns'
                            type: Array
                            description: |
                              SQL Server columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                            item_type:
                              description: |
                                SQL Server Column.
                              type: NestedObject
                              properties:
                                - name: 'column'
                                  type: String
                                  description: |
                                    Column name.
                                - name: 'dataType'
                                  type: String
                                  description: |
                                    The SQL Server data type. Full data types list can be found here:
                                    https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver16
                                - name: 'length'
                                  type: Integer
                                  description: |
                                    Column length.
                                  output: true
                                - name: 'precision'
                                  type: Integer
                                  description: |
                                    Column precision.
                                  output: true
                                - name: 'scale'
                                  type: Integer
                                  description: |
                                    Column scale.
                                  output: true
                                - name: 'primaryKey'
                                  type: Boolean
                                  description: |
                                    Whether or not the column represents a primary key.
                                  output: true
                                - name: 'nullable'
                                  type: Boolean
                                  description: |
                                    Whether or not the column can accept a null value.
                                  output: true
                                - name: 'ordinalPosition'
                                  type: Integer
                                  description: |
                                    The ordinal position of the column in the table.
                                  output: true
                            min_size: 1
                      min_size: 1
                min_size: 1
          - name: 'maxConcurrentCdcTasks'
            type: Integer
            description: |
              Max concurrent CDC tasks.
            default_from_api: true
            send_empty_value: true
            validation:
              function: 'validation.IntAtLeast(0)'
          - name: 'maxConcurrentBackfillTasks'
            type: Integer
            description: |
              Max concurrent backfill tasks.
            default_from_api: true
            send_empty_value: true
            validation:
              function: 'validation.IntAtLeast(0)'
          - name: 'transactionLogs'
            type: NestedObject
            description: |
              CDC reader reads from transaction logs.
            send_empty_value: true
            allow_empty_object: true
            properties:
              []
          - name: 'changeTables'
            type: NestedObject
            description: |
              CDC reader reads from change tables.
            send_empty_value: true
            allow_empty_object: true
            properties:
              []
      - name: 'salesforceSourceConfig'
        type: NestedObject
        description: |
          Salesforce data source configuration.
        send_empty_value: true
        allow_empty_object: true
        exactly_one_of:
          - 'source_config.0.mysql_source_config'
          - 'source_config.0.oracle_source_config'
          - 'source_config.0.postgresql_source_config'
          - 'source_config.0.sql_server_source_config'
          - 'source_config.0.salesforce_source_config'
        properties:
          - name: 'includeObjects'
            type: NestedObject
            description: |
              Salesforce objects to retrieve from the source.
            properties:
              - name: 'objects'
                type: Array
                description: |
                  Salesforce objects in Salesforce Org.
                required: true
                min_size: 1
                item_type:
                  description: |
                    Salesforce objects.
                  type: NestedObject
                  properties:
                    - name: 'objectName'
                      type: String
                      description: |
                        Name of object in Salesforce Org.
                    - name: 'fields'
                      type: Array
                      description: |
                        Fields in the Salesforce object. When unspecified as part of include/exclude objects, includes/excludes everything/nothing.
                      min_size: 1
                      item_type:
                        description: |
                          Salesforce field.
                        type: NestedObject
                        properties:
                          - name: 'name'
                            type: String
                            description: |
                              Field name.
          - name: 'excludeObjects'
            type: NestedObject
            description: |
              Salesforce objects to exclude from the stream.
            properties:
              - name: 'objects'
                type: Array
                description: |
                  Salesforce objects in data source.
                required: true
                min_size: 1
                item_type:
                  description: |
                    Salesforce objects.
                  type: NestedObject
                  properties:
                    - name: 'objectName'
                      type: String
                      description: |
                        Name of object in Salesforce Org.
                    - name: 'fields'
                      type: Array
                      description: |
                        Fields in the Salesforce object. When unspecified as part of include/exclude objects, includes/excludes everything/nothing.
                      min_size: 1
                      item_type:
                        description: |
                          Salesforce field.
                        type: NestedObject
                        properties:
                          - name: 'name'
                            type: String
                            description: |
                              Field name.
          - name: 'pollingInterval'
            type: String
            description: |
              Salesforce objects polling interval. The interval at which new changes will be polled for each object. The duration must be between 5 minutes and 24 hours.
            required: true
  - name: 'destinationConfig'
    type: NestedObject
    description: |
      Destination connection profile configuration.
    required: true
    properties:
      - name: 'destinationConnectionProfile'
        type: String
        description: |
          Destination connection profile resource. Format: projects/{project}/locations/{location}/connectionProfiles/{name}
        required: true
        immutable: true
        diff_suppress_func: 'tpgresource.ProjectNumberDiffSuppress'
      - name: 'gcsDestinationConfig'
        type: NestedObject
        description: |
          A configuration for how data should be loaded to Cloud Storage.
        exactly_one_of:
          - 'destination_config.0.gcs_destination_config'
          - 'destination_config.0.bigquery_destination_config'
        properties:
          - name: 'path'
            type: String
            description: |
              Path inside the Cloud Storage bucket to write data to.
          - name: 'fileRotationMb'
            type: Integer
            description: |
              The maximum file size to be saved in the bucket.
            default_from_api: true
          - name: 'fileRotationInterval'
            type: String
            description: |
              The maximum duration for which new events are added before a file is closed and a new file is created.
              A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s". Defaults to 900s.
            default_from_api: true
          - name: 'avroFileFormat'
            type: NestedObject
            description: |
              AVRO file format configuration.
            send_empty_value: true
            allow_empty_object: true
            exactly_one_of:
              - 'destination_config.0.gcs_destination_config.0.avro_file_format'
              - 'destination_config.0.gcs_destination_config.0.json_file_format'
            properties:
              []
          - name: 'jsonFileFormat'
            type: NestedObject
            description: |
              JSON file format configuration.
            exactly_one_of:
              - 'destination_config.0.gcs_destination_config.0.avro_file_format'
              - 'destination_config.0.gcs_destination_config.0.json_file_format'
            properties:
              - name: 'schemaFileFormat'
                type: Enum
                description: |
                  The schema file format along JSON data files.
                enum_values:
                  - 'NO_SCHEMA_FILE'
                  - 'AVRO_SCHEMA_FILE'
              - name: 'compression'
                type: Enum
                description: |
                  Compression of the loaded JSON file.
                enum_values:
                  - 'NO_COMPRESSION'
                  - 'GZIP'
      - name: 'bigqueryDestinationConfig'
        type: NestedObject
        description: |
          A configuration for how data should be loaded to Google BigQuery.
        exactly_one_of:
          - 'destination_config.0.gcs_destination_config'
          - 'destination_config.0.bigquery_destination_config'
        properties:
          - name: 'dataFreshness'
            type: String
            description: |
              The guaranteed data freshness (in seconds) when querying tables created by the stream.
              Editing this field will only affect new tables created in the future, but existing tables
              will not be impacted. Lower values mean that queries will return fresher data, but may result in higher cost.
              A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s". Defaults to 900s.
          - name: 'singleTargetDataset'
            type: NestedObject
            description: |
              A single target dataset to which all data will be streamed.
            exactly_one_of:
              - 'destination_config.0.bigquery_destination_config.0.single_target_dataset'
              - 'destination_config.0.bigquery_destination_config.0.source_hierarchy_datasets'
            properties:
              - name: 'datasetId'
                type: String
                description: |
                  Dataset ID in the format projects/{project}/datasets/{dataset_id} or
                  {project}:{dataset_id}
                required: true
                diff_suppress_func: 'resourceDatastreamStreamDatabaseIdDiffSuppress'
                custom_expand: 'templates/terraform/custom_expand/datastream_stream_dataset_id.go.tmpl'
          - name: 'sourceHierarchyDatasets'
            type: NestedObject
            description: |
              Destination datasets are created so that hierarchy of the destination data objects matches the source hierarchy.
            exactly_one_of:
              - 'destination_config.0.bigquery_destination_config.0.single_target_dataset'
              - 'destination_config.0.bigquery_destination_config.0.source_hierarchy_datasets'
            properties:
              - name: 'datasetTemplate'
                type: NestedObject
                description: |
                  Dataset template used for dynamic dataset creation.
                required: true
                properties:
                  - name: 'location'
                    type: String
                    description: |
                      The geographic location where the dataset should reside.
                      See https://cloud.google.com/bigquery/docs/locations for supported locations.
                    required: true
                  - name: 'datasetIdPrefix'
                    type: String
                    description: |
                      If supplied, every created dataset will have its name prefixed by the provided value.
                      The prefix and name will be separated by an underscore. i.e. _.
                  - name: 'kmsKeyName'
                    type: String
                    description: |
                      Describes the Cloud KMS encryption key that will be used to protect destination BigQuery
                      table. The BigQuery Service Account associated with your project requires access to this
                      encryption key. i.e. projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{cryptoKey}.
                      See https://cloud.google.com/bigquery/docs/customer-managed-encryption for more information.
                    immutable: true
          - name: 'blmtConfig'
            type: NestedObject
            description: 'BigLake Managed Tables configuration for BigQuery streams.'
            properties:
              - name: 'bucket'
                type: String
                description: |
                      The Cloud Storage bucket name.
                required: true
              - name: 'connectionName'
                type: String
                description: |
                      The bigquery connection. Format: `{project}.{location}.{name}`
                required: true
              - name: 'fileFormat'
                type: String
                description: |
                      The file format.
                required: true
                enum_values:
                  - FILE_FORMAT_UNSPECIFIED
                  - PARQUET
              - name: 'tableFormat'
                type: String
                description: |
                      The table format.
                required: true
                enum_values:
                  - TABLE_FORMAT_UNSPECIFIED
                  - ICEBERG
              - name: 'rootPath'
                type: String
                description: |
                      The root path inside the Cloud Storage bucket.
          - name: 'merge'
            type: NestedObject
            description: |
              Merge mode defines that all changes to a table will be merged at the destination Google BigQuery
              table. This is the default write mode. When selected, BigQuery reflects the way the data is stored
              in the source database. With Merge mode, no historical record of the change events is kept.
            immutable: true
            send_empty_value: true
            allow_empty_object: true
            conflicts:
              - destination_config.0.bigquery_destination_config.0.append_only
            properties:
              []
          - name: 'appendOnly'
            type: NestedObject
            description: |
              AppendOnly mode defines that the stream of changes (INSERT, UPDATE-INSERT, UPDATE-DELETE and DELETE
              events) to a source table will be written to the destination Google BigQuery table, retaining the
              historical state of the data.
            immutable: true
            send_empty_value: true
            allow_empty_object: true
            conflicts:
              - destination_config.0.bigquery_destination_config.0.merge
            properties:
              []
  - name: 'state'
    type: String
    description: The state of the stream.
    output: true
  - name: 'backfillAll'
    type: NestedObject
    description: |
      Backfill strategy to automatically backfill the Stream's objects. Specific objects can be excluded.
    send_empty_value: true
    allow_empty_object: true
    exactly_one_of:
      - 'backfill_all'
      - 'backfill_none'
    properties:
      - name: 'mysqlExcludedObjects'
        type: NestedObject
        description: |
          MySQL data source objects to avoid backfilling.
        properties:
          - name: 'mysqlDatabases'
            type: Array
            description: |
              MySQL databases on the server
            required: true
            item_type:
              description: |
                MySQL database.
              type: NestedObject
              properties:
                - name: 'database'
                  type: String
                  description: |
                    Database name.
                  required: true
                - name: 'mysqlTables'
                  type: Array
                  description: |
                    Tables in the database.
                  item_type:
                    description: |
                      MySQL table.
                    type: NestedObject
                    properties:
                      - name: 'table'
                        type: String
                        description: |
                          Table name.
                        required: true
                      - name: 'mysqlColumns'
                        type: Array
                        description: |
                          MySQL columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                        item_type:
                          description: |
                            MySQL Column.
                          type: NestedObject
                          properties:
                            - name: 'column'
                              type: String
                              description: |
                                Column name.
                            - name: 'dataType'
                              type: String
                              description: |
                                The MySQL data type. Full data types list can be found here:
                                https://dev.mysql.com/doc/refman/8.0/en/data-types.html
                            - name: 'length'
                              type: Integer
                              description: |
                                Column length.
                              output: true
                            - name: 'collation'
                              type: String
                              description: |
                                Column collation.
                            - name: 'primaryKey'
                              type: Boolean
                              description: |
                                Whether or not the column represents a primary key.
                            - name: 'nullable'
                              type: Boolean
                              description: |
                                Whether or not the column can accept a null value.
                            - name: 'ordinalPosition'
                              type: Integer
                              description: |
                                The ordinal position of the column in the table.
                        min_size: 1
                  min_size: 1
            min_size: 1
      - name: 'postgresqlExcludedObjects'
        type: NestedObject
        description: |
          PostgreSQL data source objects to avoid backfilling.
        properties:
          - name: 'postgresqlSchemas'
            type: Array
            description: |
              PostgreSQL schemas on the server
            required: true
            item_type:
              description: |
                PostgreSQL schema.
              type: NestedObject
              properties:
                - name: 'schema'
                  type: String
                  description: |
                    Database name.
                  required: true
                - name: 'postgresqlTables'
                  type: Array
                  description: |
                    Tables in the schema.
                  item_type:
                    description: |
                      PostgreSQL table.
                    type: NestedObject
                    properties:
                      - name: 'table'
                        type: String
                        description: |
                          Table name.
                        required: true
                      - name: 'postgresqlColumns'
                        type: Array
                        description: |
                          PostgreSQL columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                        item_type:
                          description: |
                            PostgreSQL Column.
                          type: NestedObject
                          properties:
                            - name: 'column'
                              type: String
                              description: |
                                Column name.
                            - name: 'dataType'
                              type: String
                              description: |
                                The PostgreSQL data type. Full data types list can be found here:
                                https://www.postgresql.org/docs/current/datatype.html
                            - name: 'length'
                              type: Integer
                              description: |
                                Column length.
                              output: true
                            - name: 'precision'
                              type: Integer
                              description: |
                                Column precision.
                              output: true
                            - name: 'scale'
                              type: Integer
                              description: |
                                Column scale.
                              output: true
                            - name: 'primaryKey'
                              type: Boolean
                              description: |
                                Whether or not the column represents a primary key.
                            - name: 'nullable'
                              type: Boolean
                              description: |
                                Whether or not the column can accept a null value.
                            - name: 'ordinalPosition'
                              type: Integer
                              description: |
                                The ordinal position of the column in the table.
                        min_size: 1
                  min_size: 1
            min_size: 1
      - name: 'oracleExcludedObjects'
        type: NestedObject
        description: |
          PostgreSQL data source objects to avoid backfilling.
        properties:
          - name: 'oracleSchemas'
            type: Array
            description: |
              Oracle schemas/databases in the database server
            required: true
            item_type:
              description: |
                MySQL database.
              type: NestedObject
              properties:
                - name: 'schema'
                  type: String
                  description: |
                    Schema name.
                  required: true
                - name: 'oracleTables'
                  type: Array
                  description: |
                    Tables in the database.
                  item_type:
                    description: |
                      Oracle table.
                    type: NestedObject
                    properties:
                      - name: 'table'
                        type: String
                        description: |
                          Table name.
                        required: true
                      - name: 'oracleColumns'
                        type: Array
                        description: |
                          Oracle columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                        item_type:
                          description: |
                            Oracle Column.
                          type: NestedObject
                          properties:
                            - name: 'column'
                              type: String
                              description: |
                                Column name.
                            - name: 'dataType'
                              type: String
                              description: |
                                The Oracle data type. Full data types list can be found here:
                                https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Data-Types.html
                            - name: 'length'
                              type: Integer
                              description: |
                                Column length.
                              output: true
                            - name: 'precision'
                              type: Integer
                              description: |
                                Column precision.
                              output: true
                            - name: 'scale'
                              type: Integer
                              description: |
                                Column scale.
                              output: true
                            - name: 'encoding'
                              type: String
                              description: |
                                Column encoding.
                              output: true
                            - name: 'primaryKey'
                              type: Boolean
                              description: |
                                Whether or not the column represents a primary key.
                              output: true
                            - name: 'nullable'
                              type: Boolean
                              description: |
                                Whether or not the column can accept a null value.
                              output: true
                            - name: 'ordinalPosition'
                              type: Integer
                              description: |
                                The ordinal position of the column in the table.
                              output: true
                        min_size: 1
                  min_size: 1
            min_size: 1
      - name: 'sqlServerExcludedObjects'
        type: NestedObject
        description: |
          SQL Server data source objects to avoid backfilling.
        properties:
          - name: 'schemas'
            type: Array
            description: |
              SQL Server schemas/databases in the database server
            required: true
            item_type:
              description: |
                SQL Server database.
              type: NestedObject
              properties:
                - name: 'schema'
                  type: String
                  description: |
                    Schema name.
                  required: true
                - name: 'tables'
                  type: Array
                  description: |
                    Tables in the database.
                  item_type:
                    description: |
                      SQL Server table.
                    type: NestedObject
                    properties:
                      - name: 'table'
                        type: String
                        description: |
                          Table name.
                        required: true
                      - name: 'columns'
                        type: Array
                        description: |
                          SQL Server columns in the schema. When unspecified as part of include/exclude objects, includes/excludes everything.
                        item_type:
                          description: |
                            SQL Server Column.
                          type: NestedObject
                          properties:
                            - name: 'column'
                              type: String
                              description: |
                                Column name.
                            - name: 'dataType'
                              type: String
                              description: |
                                The SQL Server data type. Full data types list can be found here:
                                https://learn.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver16
                            - name: 'length'
                              type: Integer
                              description: |
                                Column length.
                              output: true
                            - name: 'precision'
                              type: Integer
                              description: |
                                Column precision.
                              output: true
                            - name: 'scale'
                              type: Integer
                              description: |
                                Column scale.
                              output: true
                            - name: 'primaryKey'
                              type: Boolean
                              description: |
                                Whether or not the column represents a primary key.
                              output: true
                            - name: 'nullable'
                              type: Boolean
                              description: |
                                Whether or not the column can accept a null value.
                              output: true
                            - name: 'ordinalPosition'
                              type: Integer
                              description: |
                                The ordinal position of the column in the table.
                              output: true
                        min_size: 1
                  min_size: 1
            min_size: 1
      - name: 'salesforceExcludedObjects'
        type: NestedObject
        description: |
          Salesforce objects to avoid backfilling.
        properties:
          - name: 'objects'
            type: Array
            description: |
              Salesforce objects in Salesforce Org.
            required: true
            min_size: 1
            item_type:
              description: |
                Salesforce objects.
              type: NestedObject
              properties:
                - name: 'objectName'
                  type: String
                  description: |
                    Name of object in Salesforce Org.
                - name: 'fields'
                  type: Array
                  description: |
                    Fields in the Salesforce object. When unspecified as part of include/exclude objects, includes/excludes everything/nothing.
                  min_size: 1
                  item_type:
                    description: |
                      Salesforce field.
                    type: NestedObject
                    properties:
                      - name: 'name'
                        type: String
                        description: |
                          Field name.
  - name: 'backfillNone'
    type: NestedObject
    description: |
      Backfill strategy to disable automatic backfill for the Stream's objects.
    send_empty_value: true
    allow_empty_object: true
    exactly_one_of:
      - 'backfill_all'
      - 'backfill_none'
    properties:
      []
  - name: 'customerManagedEncryptionKey'
    type: String
    description: |
      A reference to a KMS encryption key. If provided, it will be used to encrypt the data. If left blank, data
      will be encrypted using an internal Stream-specific encryption key provisioned through KMS.
    immutable: true
