diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 4c29457..e568523 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: a76d605f-5242-4bd3-8bd6-56a119e8eec5 management: - docChecksum: 3f5b7b512239e2ae174a08744b47a8b7 + docChecksum: e88271fabb4586f51b0386879f7b3c30 docVersion: 1.0.0 speakeasyVersion: 1.346.0 generationVersion: 2.379.3 - releaseVersion: 0.5.0 - configChecksum: a3309a6e429c2e227c4300b09309fef7 + releaseVersion: 0.5.1 + configChecksum: 24f54e0e9292a2aeb4a0d21167ba222d repoURL: https://github.com/epilot-dev/terraform-provider-epilot-entitymapping.git repoSubDirectory: . published: true @@ -54,6 +54,12 @@ generatedFiles: - internal/sdk/models/operations/storeconfig.go - internal/sdk/models/operations/storenewversion.go - internal/sdk/models/shared/mappingconfig.go + - internal/sdk/models/shared/sourceconfig.go + - internal/sdk/models/shared/journeyref.go + - internal/sdk/models/shared/entityref.go + - internal/sdk/models/shared/executemappingresp.go + - internal/sdk/models/shared/mappingwarning.go + - internal/sdk/models/shared/mappingfailure.go - internal/sdk/models/shared/targetconfig.go - internal/sdk/models/shared/relationattribute.go - internal/sdk/models/shared/attributeorigin.go @@ -66,12 +72,6 @@ generatedFiles: - internal/sdk/models/shared/mappingattributemode.go - internal/sdk/models/shared/copyvaluemapper.go - internal/sdk/models/shared/appendvaluemapper.go - - internal/sdk/models/shared/sourceconfig.go - - internal/sdk/models/shared/journeyref.go - - internal/sdk/models/shared/entityref.go - - internal/sdk/models/shared/executemappingresp.go - - internal/sdk/models/shared/mappingwarning.go - - internal/sdk/models/shared/mappingfailure.go - internal/sdk/models/shared/executemappingreq.go - internal/sdk/models/shared/executerelationsresp.go - internal/sdk/models/shared/newrelationitem.go @@ -134,22 +134,6 @@ generatedFiles: - internal/provider/types/journey_ref.go - internal/provider/types/config.go - internal/provider/types/source_config.go - - internal/provider/types/loop_config.go - - internal/provider/types/append_value_mapper.go - - internal/provider/types/copy_value_mapper.go - - internal/provider/types/set_value_mapper.go - - internal/provider/types/mapping_attribute.go - - internal/provider/types/one.go - - internal/provider/types/two.go - - internal/provider/types/random_operation.go - - internal/provider/types/uniq.go - - internal/provider/types/operation_object_node.go - - internal/provider/types/operation_node.go - - internal/provider/types/mapping_attribute_v2.go - - internal/provider/types/mapping_attributes.go - - internal/provider/types/source_filter.go - - internal/provider/types/relation_attribute.go - - internal/provider/types/target_config.go - USAGE.md - internal/provider/provider.go - examples/provider/provider.tf diff --git a/README.md b/README.md index 999fdfa..457d9fe 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ terraform { required_providers { epilot-entitymapping = { source = "epilot-dev/epilot-entitymapping" - version = "0.5.0" + version = "0.5.1" } } } diff --git a/docs/data-sources/entity_mapping.md b/docs/data-sources/entity_mapping.md index 84d6470..cbf5a50 100644 --- a/docs/data-sources/entity_mapping.md +++ b/docs/data-sources/entity_mapping.md @@ -28,7 +28,7 @@ data "epilot-entitymapping_entity_mapping" "my_entitymapping" { ### Read-Only - `source` (Attributes) (see [below for nested schema](#nestedatt--source)) -- `targets` (Attributes List) (see [below for nested schema](#nestedatt--targets)) +- `targets` (String) Parsed as JSON. ### Nested Schema for `source` @@ -63,186 +63,3 @@ Read-Only: - `journey_id` (String) - - - -### Nested Schema for `targets` - -Read-Only: - -- `allow_failure` (Boolean) Pass it as true, when you don't want failures to interrupt the mapping process. -- `condition_mode` (String) Parsed as JSON. -- `conditions` (String) Parsed as JSON. -- `id` (String) Identifier for target configuration. Useful for later usages when trying to identify which target config to map to. -- `linkback_relation_attribute` (String) Relation attribute on the main entity where the target entity will be linked. Set to false to disable linkback -- `linkback_relation_tags` (List of String) Relation tags (labels) to include in main entity linkback relation attribute -- `loop_config` (Attributes) contains config in case of running in loop mode (see [below for nested schema](#nestedatt--targets--loop_config)) -- `mapping_attributes` (Attributes List) Attribute mappings (see [below for nested schema](#nestedatt--targets--mapping_attributes)) -- `name` (String) A name for this configuration -- `relation_attributes` (Attributes List) Relation mappings (see [below for nested schema](#nestedatt--targets--relation_attributes)) -- `target_schema` (String) Schema of target entity -- `target_unique` (List of String) Unique key for target entity (see upsertEntity of Entity API) - - -### Nested Schema for `targets.loop_config` - -Read-Only: - -- `length` (Number) a hard limit of how many times the loop is allowed to run. -- `source_path` (String) path to the array from the entity payload - - - -### Nested Schema for `targets.mapping_attributes` - -Read-Only: - -- `mapping_attribute` (Attributes) (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute)) -- `mapping_attribute_v2` (Attributes) (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2)) - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute` - -Read-Only: - -- `append_value_mapper` (Attributes) (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute--append_value_mapper)) -- `copy_value_mapper` (Attributes) (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute--copy_value_mapper)) -- `set_value_mapper` (Attributes) (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute--set_value_mapper)) - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute.set_value_mapper` - -Read-Only: - -- `mode` (String) - copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property. - -must be one of ["copy_if_exists", "append_if_exists", "set_value"] -- `source` (String) JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price -- `target` (String) JSON like target path for the attribute. Eg. last_name -- `target_unique` (List of String) Array of keys which should be used when checking for uniqueness. Eg: [country, city, postal_code] -- `value_json` (String) To be provided only when mapping json objects into a target attribute. Eg array of addresses. - - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute.set_value_mapper` - -Read-Only: - -- `mode` (String) - copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property. - -must be one of ["copy_if_exists", "append_if_exists", "set_value"] -- `source` (String) JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price -- `target` (String) JSON like target path for the attribute. Eg. last_name - - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute.set_value_mapper` - -Read-Only: - -- `mode` (String) - copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property. - -must be one of ["copy_if_exists", "append_if_exists", "set_value"] -- `target` (String) JSON like target path for the attribute. Eg. last_name -- `value` (String) Any value to be set: string, number, string[], number[], JSON object, etc. It will override existing values, if any. - -Parsed as JSON. - - - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2` - -Read-Only: - -- `operation` (Attributes) Mapping operation nodes are either primitive values or operation node objects (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--operation)) -- `origin` (String) Origin of an attribute. must be one of ["system_recommendation", "user_manually", "entity_updating_system_recommendation"] -- `target` (String) Target JSON path for the attribute to set - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target` - -Read-Only: - -- `any` (String) Parsed as JSON. -- `operation_object_node` (Attributes) (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--target--operation_object_node)) - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target.operation_object_node` - -Read-Only: - -- `additional_properties` (String) Parsed as JSON. -- `append` (List of String) Append to array -- `copy` (String) Copy JSONPath value from source entity context -- `random` (Attributes) (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--target--operation_object_node--random)) -- `set` (String) Parsed as JSON. -- `template` (String) Define handlebars template to output a string -- `uniq` (Attributes) Unique array (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--target--operation_object_node--uniq)) - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target.operation_object_node.uniq` - -Read-Only: - -- `one` (Attributes) (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--target--operation_object_node--uniq--one)) -- `two` (Attributes) (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--target--operation_object_node--uniq--two)) - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target.operation_object_node.uniq.two` - -Read-Only: - -- `type` (String) must be one of ["uuid", "nanoid"] - - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target.operation_object_node.uniq.two` - -Read-Only: - -- `max` (Number) -- `min` (Number) -- `type` (String) must be one of ["number"] - - - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target.operation_object_node.uniq` - -Read-Only: - -- `array_of_str` (List of String) -- `boolean` (Boolean) - - - - - - - -### Nested Schema for `targets.relation_attributes` - -Read-Only: - -- `mode` (String) must be one of ["append", "prepend", "set"] -- `origin` (String) Origin of an attribute. must be one of ["system_recommendation", "user_manually", "entity_updating_system_recommendation"] -- `related_to` (Map of String) -- `source_filter` (Attributes) A filter to identify which source entities to pick as relations from main entity (see [below for nested schema](#nestedatt--targets--relation_attributes--source_filter)) -- `target` (String) Target attribute to store the relation in -- `target_tags` (List of String) Relation tags (labels) to set for the stored relations -- `target_tags_include_source` (Boolean) Include all relation tags (labels) present on the main entity relation - - -### Nested Schema for `targets.relation_attributes.source_filter` - -Read-Only: - -- `attribute` (String) Filter by a specific relation attribute on the main entity -- `limit` (Number) Limit relations to maximum number (default, all matched relations) -- `relation_tag` (String) Filter by relation tag (label) on the main entity -- `schema` (String) Filter by specific schema -- `self` (Boolean) Picks main entity as relation (overrides other filters) -- `tag` (String) Filter by a specific tag on the related entity - - diff --git a/docs/index.md b/docs/index.md index fc9383a..62e7a15 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ terraform { required_providers { epilot-entitymapping = { source = "epilot-dev/epilot-entitymapping" - version = "0.5.0" + version = "0.5.1" } } } diff --git a/docs/resources/entity_mapping.md b/docs/resources/entity_mapping.md index f60d1a7..7040b89 100644 --- a/docs/resources/entity_mapping.md +++ b/docs/resources/entity_mapping.md @@ -24,65 +24,7 @@ resource "epilot-entitymapping_entity_mapping" "my_entitymapping" { } type = "journey" } - targets = [ - { - allow_failure = false - condition_mode = "{ \"see\": \"documentation\" }" - conditions = "{ \"see\": \"documentation\" }" - id = "cd4d3a54-7d70-4901-810e-0737604f94fa" - linkback_relation_attribute = "...my_linkback_relation_attribute..." - linkback_relation_tags = [ - "...", - ] - loop_config = { - length = 69.48 - source_path = "...my_source_path..." - } - mapping_attributes = [ - { - mapping_attribute = { - append_value_mapper = { - mode = "set_value" - source = "...my_source..." - target = "...my_target..." - target_unique = [ - "...", - ] - value_json = "...my_value_json..." - } - } - }, - ] - name = "Amos Kirlin" - relation_attributes = [ - { - mode = "prepend" - origin = "user_manually" - related_to = { - "Rubber" = "{ \"see\": \"documentation\" }" - "North" = "{ \"see\": \"documentation\" }" - } - source_filter = { - attribute = "...my_attribute..." - limit = 9 - relation_tag = "...my_relation_tag..." - schema = "...my_schema..." - self = false - tag = "...my_tag..." - } - target = "...my_target..." - target_tags = [ - "...", - ] - target_tags_include_source = true - }, - ] - target_schema = "...my_target_schema..." - target_unique = [ - "...", - ] - }, - ] + targets = "{ \"see\": \"documentation\" }" } ``` @@ -93,7 +35,7 @@ resource "epilot-entitymapping_entity_mapping" "my_entitymapping" { - `id` (String) Mapping Config Id. Requires replacement if changed. - `source` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--source)) -- `targets` (Attributes List) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets)) +- `targets` (String) Parsed as JSON. ### Nested Schema for `source` @@ -127,199 +69,6 @@ Optional: - `journey_id` (String) Requires replacement if changed. - - - - -### Nested Schema for `targets` - -Optional: - -- `allow_failure` (Boolean) Pass it as true, when you don't want failures to interrupt the mapping process. Requires replacement if changed. -- `condition_mode` (String) Parsed as JSON. -- `conditions` (String) Parsed as JSON. -- `id` (String) Identifier for target configuration. Useful for later usages when trying to identify which target config to map to. Requires replacement if changed. -- `linkback_relation_attribute` (String) Relation attribute on the main entity where the target entity will be linked. Set to false to disable linkback - -Requires replacement if changed. ; Default: "mapped_entities" -- `linkback_relation_tags` (List of String) Relation tags (labels) to include in main entity linkback relation attribute. Requires replacement if changed. -- `loop_config` (Attributes) contains config in case of running in loop mode. Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--loop_config)) -- `mapping_attributes` (Attributes List) Attribute mappings. Requires replacement if changed. ; Not Null (see [below for nested schema](#nestedatt--targets--mapping_attributes)) -- `name` (String) A name for this configuration. Requires replacement if changed. -- `relation_attributes` (Attributes List) Relation mappings. Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--relation_attributes)) -- `target_schema` (String) Schema of target entity. Requires replacement if changed. ; Not Null -- `target_unique` (List of String) Unique key for target entity (see upsertEntity of Entity API). Requires replacement if changed. - - -### Nested Schema for `targets.loop_config` - -Optional: - -- `length` (Number) a hard limit of how many times the loop is allowed to run. Requires replacement if changed. ; Default: "the length of the array" -- `source_path` (String) path to the array from the entity payload. Requires replacement if changed. - - - -### Nested Schema for `targets.mapping_attributes` - -Optional: - -- `mapping_attribute` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute)) -- `mapping_attribute_v2` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2)) - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute` - -Optional: - -- `append_value_mapper` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute--append_value_mapper)) -- `copy_value_mapper` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute--copy_value_mapper)) -- `set_value_mapper` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute--set_value_mapper)) - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute.set_value_mapper` - -Optional: - -- `mode` (String) - copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property. - -Requires replacement if changed. ; Not Null; must be one of ["copy_if_exists", "append_if_exists", "set_value"] -- `source` (String) JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price - -Requires replacement if changed. -- `target` (String) JSON like target path for the attribute. Eg. last_name. Requires replacement if changed. ; Not Null -- `target_unique` (List of String) Array of keys which should be used when checking for uniqueness. Eg: [country, city, postal_code] - -Requires replacement if changed. -- `value_json` (String) To be provided only when mapping json objects into a target attribute. Eg array of addresses. - -Requires replacement if changed. ; Not Null - - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute.set_value_mapper` - -Optional: - -- `mode` (String) - copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property. - -Requires replacement if changed. ; Not Null; must be one of ["copy_if_exists", "append_if_exists", "set_value"] -- `source` (String) JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price - -Requires replacement if changed. ; Not Null -- `target` (String) JSON like target path for the attribute. Eg. last_name. Requires replacement if changed. ; Not Null - - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute.set_value_mapper` - -Optional: - -- `mode` (String) - copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property. - -Requires replacement if changed. ; Not Null; must be one of ["copy_if_exists", "append_if_exists", "set_value"] -- `target` (String) JSON like target path for the attribute. Eg. last_name. Requires replacement if changed. ; Not Null -- `value` (String) Any value to be set: string, number, string[], number[], JSON object, etc. It will override existing values, if any. - -Parsed as JSON. - - - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2` - -Optional: - -- `operation` (Attributes) Mapping operation nodes are either primitive values or operation node objects. Requires replacement if changed. ; Not Null (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--operation)) -- `origin` (String) Origin of an attribute. Requires replacement if changed. ; must be one of ["system_recommendation", "user_manually", "entity_updating_system_recommendation"] -- `target` (String) Target JSON path for the attribute to set. Requires replacement if changed. ; Not Null - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target` - -Optional: - -- `any` (String) Parsed as JSON. -- `operation_object_node` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--target--operation_object_node)) - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target.operation_object_node` - -Optional: - -- `additional_properties` (String) Parsed as JSON. -- `append` (List of String) Append to array. Requires replacement if changed. -- `copy` (String) Copy JSONPath value from source entity context. Requires replacement if changed. -- `random` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--target--operation_object_node--random)) -- `set` (String) Parsed as JSON. -- `template` (String) Define handlebars template to output a string. Requires replacement if changed. -- `uniq` (Attributes) Unique array. Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--target--operation_object_node--uniq)) - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target.operation_object_node.uniq` - -Optional: - -- `one` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--target--operation_object_node--uniq--one)) -- `two` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--mapping_attributes--mapping_attribute_v2--target--operation_object_node--uniq--two)) - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target.operation_object_node.uniq.two` - -Optional: - -- `type` (String) Requires replacement if changed. ; Not Null; must be one of ["uuid", "nanoid"] - - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target.operation_object_node.uniq.two` - -Optional: - -- `max` (Number) Requires replacement if changed. ; Default: 1 -- `min` (Number) Requires replacement if changed. ; Default: 0 -- `type` (String) Requires replacement if changed. ; Not Null; must be one of ["number"] - - - - -### Nested Schema for `targets.mapping_attributes.mapping_attribute_v2.target.operation_object_node.uniq` - -Optional: - -- `array_of_str` (List of String) Requires replacement if changed. -- `boolean` (Boolean) Requires replacement if changed. - - - - - - - -### Nested Schema for `targets.relation_attributes` - -Optional: - -- `mode` (String) Requires replacement if changed. ; Not Null; must be one of ["append", "prepend", "set"] -- `origin` (String) Origin of an attribute. Requires replacement if changed. ; must be one of ["system_recommendation", "user_manually", "entity_updating_system_recommendation"] -- `related_to` (Map of String) Requires replacement if changed. -- `source_filter` (Attributes) A filter to identify which source entities to pick as relations from main entity. Requires replacement if changed. (see [below for nested schema](#nestedatt--targets--relation_attributes--source_filter)) -- `target` (String) Target attribute to store the relation in. Requires replacement if changed. ; Not Null -- `target_tags` (List of String) Relation tags (labels) to set for the stored relations. Requires replacement if changed. -- `target_tags_include_source` (Boolean) Include all relation tags (labels) present on the main entity relation. Requires replacement if changed. ; Default: false - - -### Nested Schema for `targets.relation_attributes.source_filter` - -Optional: - -- `attribute` (String) Filter by a specific relation attribute on the main entity. Requires replacement if changed. -- `limit` (Number) Limit relations to maximum number (default, all matched relations). Requires replacement if changed. -- `relation_tag` (String) Filter by relation tag (label) on the main entity. Requires replacement if changed. -- `schema` (String) Filter by specific schema. Requires replacement if changed. -- `self` (Boolean) Picks main entity as relation (overrides other filters). Requires replacement if changed. ; Default: false -- `tag` (String) Filter by a specific tag on the related entity. Requires replacement if changed. - ## Import Import is supported using the following syntax: diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 8646a15..5077fa4 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { epilot-entitymapping = { source = "epilot-dev/epilot-entitymapping" - version = "0.5.0" + version = "0.5.1" } } } diff --git a/examples/resources/epilot-entitymapping_entity_mapping/resource.tf b/examples/resources/epilot-entitymapping_entity_mapping/resource.tf index aa3b893..81257c8 100644 --- a/examples/resources/epilot-entitymapping_entity_mapping/resource.tf +++ b/examples/resources/epilot-entitymapping_entity_mapping/resource.tf @@ -9,63 +9,5 @@ resource "epilot-entitymapping_entity_mapping" "my_entitymapping" { } type = "journey" } - targets = [ - { - allow_failure = false - condition_mode = "{ \"see\": \"documentation\" }" - conditions = "{ \"see\": \"documentation\" }" - id = "cd4d3a54-7d70-4901-810e-0737604f94fa" - linkback_relation_attribute = "...my_linkback_relation_attribute..." - linkback_relation_tags = [ - "...", - ] - loop_config = { - length = 69.48 - source_path = "...my_source_path..." - } - mapping_attributes = [ - { - mapping_attribute = { - append_value_mapper = { - mode = "set_value" - source = "...my_source..." - target = "...my_target..." - target_unique = [ - "...", - ] - value_json = "...my_value_json..." - } - } - }, - ] - name = "Amos Kirlin" - relation_attributes = [ - { - mode = "prepend" - origin = "user_manually" - related_to = { - "Rubber" = "{ \"see\": \"documentation\" }" - "North" = "{ \"see\": \"documentation\" }" - } - source_filter = { - attribute = "...my_attribute..." - limit = 9 - relation_tag = "...my_relation_tag..." - schema = "...my_schema..." - self = false - tag = "...my_tag..." - } - target = "...my_target..." - target_tags = [ - "...", - ] - target_tags_include_source = true - }, - ] - target_schema = "...my_target_schema..." - target_unique = [ - "...", - ] - }, - ] + targets = "{ \"see\": \"documentation\" }" } \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index f3dcc7a..2b47cdf 100755 --- a/gen.yaml +++ b/gen.yaml @@ -13,7 +13,7 @@ generation: sdkFlattening: true telemetryEnabled: false terraform: - version: 0.5.0 + version: 0.5.1 additionalDataSources: [] additionalDependencies: {} additionalResources: [] diff --git a/internal/provider/entitymapping_data_source.go b/internal/provider/entitymapping_data_source.go index f173e4d..d52b176 100644 --- a/internal/provider/entitymapping_data_source.go +++ b/internal/provider/entitymapping_data_source.go @@ -29,9 +29,9 @@ type EntityMappingDataSource struct { // EntityMappingDataSourceModel describes the data model. type EntityMappingDataSourceModel struct { - ID types.String `tfsdk:"id"` - Source tfTypes.SourceConfig `tfsdk:"source"` - Targets []tfTypes.TargetConfig `tfsdk:"targets"` + ID types.String `tfsdk:"id"` + Source tfTypes.SourceConfig `tfsdk:"source"` + Targets types.String `tfsdk:"targets"` } // Metadata returns the data source type name. @@ -84,304 +84,9 @@ func (r *EntityMappingDataSource) Schema(ctx context.Context, req datasource.Sch }, }, }, - "targets": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "allow_failure": schema.BoolAttribute{ - Computed: true, - Description: `Pass it as true, when you don't want failures to interrupt the mapping process.`, - }, - "condition_mode": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - }, - "conditions": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - }, - "id": schema.StringAttribute{ - Computed: true, - Description: `Identifier for target configuration. Useful for later usages when trying to identify which target config to map to.`, - }, - "linkback_relation_attribute": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `Relation attribute on the main entity where the target entity will be linked. Set to false to disable linkback` + "\n" + - ``, - }, - "linkback_relation_tags": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Relation tags (labels) to include in main entity linkback relation attribute`, - }, - "loop_config": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "length": schema.NumberAttribute{ - Computed: true, - Description: `a hard limit of how many times the loop is allowed to run.`, - }, - "source_path": schema.StringAttribute{ - Computed: true, - Description: `path to the array from the entity payload`, - }, - }, - Description: `contains config in case of running in loop mode`, - }, - "mapping_attributes": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "mapping_attribute": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "append_value_mapper": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "mode": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `- copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property.` + "\n" + - `` + "\n" + - `must be one of ["copy_if_exists", "append_if_exists", "set_value"]`, - }, - "source": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price` + "\n" + - ``, - }, - "target": schema.StringAttribute{ - Computed: true, - Description: `JSON like target path for the attribute. Eg. last_name`, - }, - "target_unique": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - MarkdownDescription: `Array of keys which should be used when checking for uniqueness. Eg: [country, city, postal_code]` + "\n" + - ``, - }, - "value_json": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `To be provided only when mapping json objects into a target attribute. Eg array of addresses.` + "\n" + - ``, - }, - }, - }, - "copy_value_mapper": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "mode": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `- copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property.` + "\n" + - `` + "\n" + - `must be one of ["copy_if_exists", "append_if_exists", "set_value"]`, - }, - "source": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price` + "\n" + - ``, - }, - "target": schema.StringAttribute{ - Computed: true, - Description: `JSON like target path for the attribute. Eg. last_name`, - }, - }, - }, - "set_value_mapper": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "mode": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `- copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property.` + "\n" + - `` + "\n" + - `must be one of ["copy_if_exists", "append_if_exists", "set_value"]`, - }, - "target": schema.StringAttribute{ - Computed: true, - Description: `JSON like target path for the attribute. Eg. last_name`, - }, - "value": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `Any value to be set: string, number, string[], number[], JSON object, etc. It will override existing values, if any.` + "\n" + - `` + "\n" + - `Parsed as JSON.`, - }, - }, - }, - }, - }, - "mapping_attribute_v2": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "operation": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "any": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - }, - "operation_object_node": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "append": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Append to array`, - }, - "copy": schema.StringAttribute{ - Computed: true, - Description: `Copy JSONPath value from source entity context`, - }, - "random": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "one": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "type": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["uuid", "nanoid"]`, - }, - }, - }, - "two": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "max": schema.NumberAttribute{ - Computed: true, - }, - "min": schema.NumberAttribute{ - Computed: true, - }, - "type": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["number"]`, - }, - }, - }, - }, - }, - "set": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - }, - "template": schema.StringAttribute{ - Computed: true, - Description: `Define handlebars template to output a string`, - }, - "uniq": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "boolean": schema.BoolAttribute{ - Computed: true, - }, - "array_of_str": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - Description: `Unique array`, - }, - "additional_properties": schema.StringAttribute{ - Computed: true, - Description: `Parsed as JSON.`, - }, - }, - }, - }, - Description: `Mapping operation nodes are either primitive values or operation node objects`, - }, - "origin": schema.StringAttribute{ - Computed: true, - Description: `Origin of an attribute. must be one of ["system_recommendation", "user_manually", "entity_updating_system_recommendation"]`, - }, - "target": schema.StringAttribute{ - Computed: true, - Description: `Target JSON path for the attribute to set`, - }, - }, - }, - }, - }, - Description: `Attribute mappings`, - }, - "name": schema.StringAttribute{ - Computed: true, - Description: `A name for this configuration`, - }, - "relation_attributes": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "mode": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["append", "prepend", "set"]`, - }, - "origin": schema.StringAttribute{ - Computed: true, - Description: `Origin of an attribute. must be one of ["system_recommendation", "user_manually", "entity_updating_system_recommendation"]`, - }, - "related_to": schema.MapAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "source_filter": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "attribute": schema.StringAttribute{ - Computed: true, - Description: `Filter by a specific relation attribute on the main entity`, - }, - "limit": schema.Int64Attribute{ - Computed: true, - Description: `Limit relations to maximum number (default, all matched relations)`, - }, - "relation_tag": schema.StringAttribute{ - Computed: true, - Description: `Filter by relation tag (label) on the main entity`, - }, - "schema": schema.StringAttribute{ - Computed: true, - Description: `Filter by specific schema`, - }, - "self": schema.BoolAttribute{ - Computed: true, - Description: `Picks main entity as relation (overrides other filters)`, - }, - "tag": schema.StringAttribute{ - Computed: true, - Description: `Filter by a specific tag on the related entity`, - }, - }, - Description: `A filter to identify which source entities to pick as relations from main entity`, - }, - "target": schema.StringAttribute{ - Computed: true, - Description: `Target attribute to store the relation in`, - }, - "target_tags": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Relation tags (labels) to set for the stored relations`, - }, - "target_tags_include_source": schema.BoolAttribute{ - Computed: true, - Description: `Include all relation tags (labels) present on the main entity relation`, - }, - }, - }, - Description: `Relation mappings`, - }, - "target_schema": schema.StringAttribute{ - Computed: true, - Description: `Schema of target entity`, - }, - "target_unique": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Unique key for target entity (see upsertEntity of Entity API)`, - }, - }, - }, + "targets": schema.StringAttribute{ + Computed: true, + Description: `Parsed as JSON.`, }, }, } diff --git a/internal/provider/entitymapping_data_source_sdk.go b/internal/provider/entitymapping_data_source_sdk.go index 4e367c5..ebd96f7 100644 --- a/internal/provider/entitymapping_data_source_sdk.go +++ b/internal/provider/entitymapping_data_source_sdk.go @@ -7,7 +7,6 @@ import ( tfTypes "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/provider/types" "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/sdk/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" - "math/big" ) func (r *EntityMappingDataSourceModel) RefreshFromSharedMappingConfigV2(resp *shared.MappingConfigV2) { @@ -32,220 +31,7 @@ func (r *EntityMappingDataSourceModel) RefreshFromSharedMappingConfigV2(resp *sh } else { r.Source.Type = types.StringNull() } - r.Targets = []tfTypes.TargetConfig{} - if len(r.Targets) > len(resp.Targets) { - r.Targets = r.Targets[:len(resp.Targets)] - } - for targetsCount, targetsItem := range resp.Targets { - var targets1 tfTypes.TargetConfig - targets1.AllowFailure = types.BoolPointerValue(targetsItem.AllowFailure) - if targetsItem.ConditionMode == nil { - targets1.ConditionMode = types.StringNull() - } else { - conditionModeResult, _ := json.Marshal(targetsItem.ConditionMode) - targets1.ConditionMode = types.StringValue(string(conditionModeResult)) - } - if targetsItem.Conditions == nil { - targets1.Conditions = types.StringNull() - } else { - conditionsResult, _ := json.Marshal(targetsItem.Conditions) - targets1.Conditions = types.StringValue(string(conditionsResult)) - } - targets1.ID = types.StringPointerValue(targetsItem.ID) - targets1.LinkbackRelationAttribute = types.StringPointerValue(targetsItem.LinkbackRelationAttribute) - targets1.LinkbackRelationTags = []types.String{} - for _, v := range targetsItem.LinkbackRelationTags { - targets1.LinkbackRelationTags = append(targets1.LinkbackRelationTags, types.StringValue(v)) - } - if targetsItem.LoopConfig == nil { - targets1.LoopConfig = nil - } else { - targets1.LoopConfig = &tfTypes.LoopConfig{} - if targetsItem.LoopConfig.Length != nil { - targets1.LoopConfig.Length = types.NumberValue(big.NewFloat(float64(*targetsItem.LoopConfig.Length))) - } else { - targets1.LoopConfig.Length = types.NumberNull() - } - targets1.LoopConfig.SourcePath = types.StringPointerValue(targetsItem.LoopConfig.SourcePath) - } - targets1.MappingAttributes = []tfTypes.MappingAttributes{} - for mappingAttributesCount, mappingAttributesItem := range targetsItem.MappingAttributes { - var mappingAttributes1 tfTypes.MappingAttributes - if mappingAttributesItem.MappingAttribute != nil { - mappingAttributes1.MappingAttribute = &tfTypes.MappingAttribute{} - if mappingAttributesItem.MappingAttribute.AppendValueMapper != nil { - mappingAttributes1.MappingAttribute.AppendValueMapper = &tfTypes.AppendValueMapper{} - mappingAttributes1.MappingAttribute.AppendValueMapper.Mode = types.StringValue(string(mappingAttributesItem.MappingAttribute.AppendValueMapper.Mode)) - mappingAttributes1.MappingAttribute.AppendValueMapper.Source = types.StringPointerValue(mappingAttributesItem.MappingAttribute.AppendValueMapper.Source) - mappingAttributes1.MappingAttribute.AppendValueMapper.Target = types.StringValue(mappingAttributesItem.MappingAttribute.AppendValueMapper.Target) - mappingAttributes1.MappingAttribute.AppendValueMapper.TargetUnique = []types.String{} - for _, v := range mappingAttributesItem.MappingAttribute.AppendValueMapper.TargetUnique { - mappingAttributes1.MappingAttribute.AppendValueMapper.TargetUnique = append(mappingAttributes1.MappingAttribute.AppendValueMapper.TargetUnique, types.StringValue(v)) - } - mappingAttributes1.MappingAttribute.AppendValueMapper.ValueJSON = types.StringValue(mappingAttributesItem.MappingAttribute.AppendValueMapper.ValueJSON) - } - if mappingAttributesItem.MappingAttribute.CopyValueMapper != nil { - mappingAttributes1.MappingAttribute.CopyValueMapper = &tfTypes.CopyValueMapper{} - mappingAttributes1.MappingAttribute.CopyValueMapper.Mode = types.StringValue(string(mappingAttributesItem.MappingAttribute.CopyValueMapper.Mode)) - mappingAttributes1.MappingAttribute.CopyValueMapper.Source = types.StringValue(mappingAttributesItem.MappingAttribute.CopyValueMapper.Source) - mappingAttributes1.MappingAttribute.CopyValueMapper.Target = types.StringValue(mappingAttributesItem.MappingAttribute.CopyValueMapper.Target) - } - if mappingAttributesItem.MappingAttribute.SetValueMapper != nil { - mappingAttributes1.MappingAttribute.SetValueMapper = &tfTypes.SetValueMapper{} - mappingAttributes1.MappingAttribute.SetValueMapper.Mode = types.StringValue(string(mappingAttributesItem.MappingAttribute.SetValueMapper.Mode)) - mappingAttributes1.MappingAttribute.SetValueMapper.Target = types.StringValue(mappingAttributesItem.MappingAttribute.SetValueMapper.Target) - valueResult, _ := json.Marshal(mappingAttributesItem.MappingAttribute.SetValueMapper.Value) - mappingAttributes1.MappingAttribute.SetValueMapper.Value = types.StringValue(string(valueResult)) - } - } - if mappingAttributesItem.MappingAttributeV2 != nil { - mappingAttributes1.MappingAttributeV2 = &tfTypes.MappingAttributeV2{} - if mappingAttributesItem.MappingAttributeV2.Operation.Any != nil { - anyResult, _ := json.Marshal(mappingAttributesItem.MappingAttributeV2.Operation.Any) - mappingAttributes1.MappingAttributeV2.Operation.Any = types.StringValue(string(anyResult)) - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode = &tfTypes.OperationObjectNode{} - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Append = nil - for _, appendItem := range mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Append { - var append2 types.String - append2Result, _ := json.Marshal(appendItem) - append2 = types.StringValue(string(append2Result)) - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Append = append(mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Append, append2) - } - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Copy = types.StringPointerValue(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Copy) - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random == nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random = nil - } else { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random = &tfTypes.RandomOperation{} - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.One != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.One = &tfTypes.One{} - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.One.Type = types.StringValue(string(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.One.Type)) - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two = &tfTypes.Two{} - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max = types.NumberValue(big.NewFloat(float64(*mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max))) - } else { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max = types.NumberNull() - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min = types.NumberValue(big.NewFloat(float64(*mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min))) - } else { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min = types.NumberNull() - } - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Type = types.StringValue(string(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Type)) - } - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Set == nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Set = types.StringNull() - } else { - setResult, _ := json.Marshal(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Set) - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Set = types.StringValue(string(setResult)) - } - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Template = types.StringPointerValue(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Template) - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq == nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq = nil - } else { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq = &tfTypes.Uniq{} - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.Boolean != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq.Boolean = types.BoolPointerValue(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.Boolean) - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr = []types.String{} - for _, v := range mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr = append(mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr, types.StringValue(v)) - } - } - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties == nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties = types.StringNull() - } else { - additionalPropertiesResult, _ := json.Marshal(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties) - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties = types.StringValue(string(additionalPropertiesResult)) - } - } - if mappingAttributesItem.MappingAttributeV2.Origin != nil { - mappingAttributes1.MappingAttributeV2.Origin = types.StringValue(string(*mappingAttributesItem.MappingAttributeV2.Origin)) - } else { - mappingAttributes1.MappingAttributeV2.Origin = types.StringNull() - } - mappingAttributes1.MappingAttributeV2.Target = types.StringValue(mappingAttributesItem.MappingAttributeV2.Target) - } - if mappingAttributesCount+1 > len(targets1.MappingAttributes) { - targets1.MappingAttributes = append(targets1.MappingAttributes, mappingAttributes1) - } else { - targets1.MappingAttributes[mappingAttributesCount].MappingAttribute = mappingAttributes1.MappingAttribute - targets1.MappingAttributes[mappingAttributesCount].MappingAttributeV2 = mappingAttributes1.MappingAttributeV2 - } - } - targets1.Name = types.StringPointerValue(targetsItem.Name) - targets1.RelationAttributes = []tfTypes.RelationAttribute{} - for relationAttributesCount, relationAttributesItem := range targetsItem.RelationAttributes { - var relationAttributes1 tfTypes.RelationAttribute - relationAttributes1.Mode = types.StringValue(string(relationAttributesItem.Mode)) - if relationAttributesItem.Origin != nil { - relationAttributes1.Origin = types.StringValue(string(*relationAttributesItem.Origin)) - } else { - relationAttributes1.Origin = types.StringNull() - } - if len(relationAttributesItem.RelatedTo) > 0 { - relationAttributes1.RelatedTo = make(map[string]types.String) - for key, value1 := range relationAttributesItem.RelatedTo { - result, _ := json.Marshal(value1) - relationAttributes1.RelatedTo[key] = types.StringValue(string(result)) - } - } - if relationAttributesItem.SourceFilter == nil { - relationAttributes1.SourceFilter = nil - } else { - relationAttributes1.SourceFilter = &tfTypes.SourceFilter{} - relationAttributes1.SourceFilter.Attribute = types.StringPointerValue(relationAttributesItem.SourceFilter.Attribute) - relationAttributes1.SourceFilter.Limit = types.Int64PointerValue(relationAttributesItem.SourceFilter.Limit) - relationAttributes1.SourceFilter.RelationTag = types.StringPointerValue(relationAttributesItem.SourceFilter.RelationTag) - relationAttributes1.SourceFilter.Schema = types.StringPointerValue(relationAttributesItem.SourceFilter.Schema) - relationAttributes1.SourceFilter.Self = types.BoolPointerValue(relationAttributesItem.SourceFilter.Self) - relationAttributes1.SourceFilter.Tag = types.StringPointerValue(relationAttributesItem.SourceFilter.Tag) - } - relationAttributes1.Target = types.StringValue(relationAttributesItem.Target) - relationAttributes1.TargetTags = []types.String{} - for _, v := range relationAttributesItem.TargetTags { - relationAttributes1.TargetTags = append(relationAttributes1.TargetTags, types.StringValue(v)) - } - relationAttributes1.TargetTagsIncludeSource = types.BoolPointerValue(relationAttributesItem.TargetTagsIncludeSource) - if relationAttributesCount+1 > len(targets1.RelationAttributes) { - targets1.RelationAttributes = append(targets1.RelationAttributes, relationAttributes1) - } else { - targets1.RelationAttributes[relationAttributesCount].Mode = relationAttributes1.Mode - targets1.RelationAttributes[relationAttributesCount].Origin = relationAttributes1.Origin - targets1.RelationAttributes[relationAttributesCount].RelatedTo = relationAttributes1.RelatedTo - targets1.RelationAttributes[relationAttributesCount].SourceFilter = relationAttributes1.SourceFilter - targets1.RelationAttributes[relationAttributesCount].Target = relationAttributes1.Target - targets1.RelationAttributes[relationAttributesCount].TargetTags = relationAttributes1.TargetTags - targets1.RelationAttributes[relationAttributesCount].TargetTagsIncludeSource = relationAttributes1.TargetTagsIncludeSource - } - } - targets1.TargetSchema = types.StringValue(targetsItem.TargetSchema) - targets1.TargetUnique = []types.String{} - for _, v := range targetsItem.TargetUnique { - targets1.TargetUnique = append(targets1.TargetUnique, types.StringValue(v)) - } - if targetsCount+1 > len(r.Targets) { - r.Targets = append(r.Targets, targets1) - } else { - r.Targets[targetsCount].AllowFailure = targets1.AllowFailure - r.Targets[targetsCount].ConditionMode = targets1.ConditionMode - r.Targets[targetsCount].Conditions = targets1.Conditions - r.Targets[targetsCount].ID = targets1.ID - r.Targets[targetsCount].LinkbackRelationAttribute = targets1.LinkbackRelationAttribute - r.Targets[targetsCount].LinkbackRelationTags = targets1.LinkbackRelationTags - r.Targets[targetsCount].LoopConfig = targets1.LoopConfig - r.Targets[targetsCount].MappingAttributes = targets1.MappingAttributes - r.Targets[targetsCount].Name = targets1.Name - r.Targets[targetsCount].RelationAttributes = targets1.RelationAttributes - r.Targets[targetsCount].TargetSchema = targets1.TargetSchema - r.Targets[targetsCount].TargetUnique = targets1.TargetUnique - } - } + targetsResult, _ := json.Marshal(resp.Targets) + r.Targets = types.StringValue(string(targetsResult)) } } diff --git a/internal/provider/entitymapping_resource.go b/internal/provider/entitymapping_resource.go index 522798d..5c77f1f 100644 --- a/internal/provider/entitymapping_resource.go +++ b/internal/provider/entitymapping_resource.go @@ -5,43 +5,24 @@ package provider import ( "context" "fmt" - speakeasy_boolplanmodifier "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/planmodifiers/boolplanmodifier" - speakeasy_int64planmodifier "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/planmodifiers/int64planmodifier" - speakeasy_listplanmodifier "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/planmodifiers/listplanmodifier" - speakeasy_mapplanmodifier "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/planmodifiers/mapplanmodifier" - speakeasy_numberplanmodifier "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/planmodifiers/numberplanmodifier" speakeasy_objectplanmodifier "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/planmodifiers/objectplanmodifier" speakeasy_stringplanmodifier "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/planmodifiers/stringplanmodifier" tfTypes "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/provider/types" "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/sdk" "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/validators" - speakeasy_listvalidators "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/validators/listvalidators" - speakeasy_objectvalidators "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/validators/objectvalidators" speakeasy_stringvalidators "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/validators/stringvalidators" - "github.com/hashicorp/terraform-plugin-framework-validators/boolvalidator" - "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" - "github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "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/booldefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" - "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/mapplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/numberdefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/numberplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "math/big" ) // Ensure provider defined types fully satisfy framework interfaces. @@ -59,9 +40,9 @@ type EntityMappingResource struct { // EntityMappingResourceModel describes the resource data model. type EntityMappingResourceModel struct { - ID types.String `tfsdk:"id"` - Source tfTypes.SourceConfig `tfsdk:"source"` - Targets []tfTypes.TargetConfig `tfsdk:"targets"` + ID types.String `tfsdk:"id"` + Source tfTypes.SourceConfig `tfsdk:"source"` + Targets types.String `tfsdk:"targets"` } func (r *EntityMappingResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -181,829 +162,16 @@ func (r *EntityMappingResource) Schema(ctx context.Context, req resource.SchemaR }, Description: `Requires replacement if changed. `, }, - "targets": schema.ListNestedAttribute{ - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), + "targets": schema.StringAttribute{ + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Required: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "allow_failure": schema.BoolAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_boolplanmodifier.SuppressDiff(speakeasy_boolplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Pass it as true, when you don't want failures to interrupt the mapping process. Requires replacement if changed. `, - }, - "condition_mode": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Parsed as JSON.`, - Validators: []validator.String{ - validators.IsValidJSON(), - }, - }, - "conditions": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Parsed as JSON.`, - Validators: []validator.String{ - validators.IsValidJSON(), - }, - }, - "id": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Identifier for target configuration. Useful for later usages when trying to identify which target config to map to. Requires replacement if changed. `, - }, - "linkback_relation_attribute": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Default: stringdefault.StaticString("mapped_entities"), - MarkdownDescription: `Relation attribute on the main entity where the target entity will be linked. Set to false to disable linkback` + "\n" + - `` + "\n" + - `Requires replacement if changed. ; Default: "mapped_entities"`, - }, - "linkback_relation_tags": schema.ListAttribute{ - Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, - Optional: true, - ElementType: types.StringType, - Description: `Relation tags (labels) to include in main entity linkback relation attribute. Requires replacement if changed. `, - }, - "loop_config": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "length": schema.NumberAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Number{ - numberplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_numberplanmodifier.SuppressDiff(speakeasy_numberplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `a hard limit of how many times the loop is allowed to run. Requires replacement if changed. ; Default: "the length of the array"`, - }, - "source_path": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `path to the array from the entity payload. Requires replacement if changed. `, - }, - }, - Description: `contains config in case of running in loop mode. Requires replacement if changed. `, - }, - "mapping_attributes": schema.ListNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "mapping_attribute": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "append_value_mapper": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "mode": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - MarkdownDescription: `- copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property.` + "\n" + - `` + "\n" + - `Requires replacement if changed. ; Not Null; must be one of ["copy_if_exists", "append_if_exists", "set_value"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "copy_if_exists", - "append_if_exists", - "set_value", - ), - }, - }, - "source": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - MarkdownDescription: `JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price` + "\n" + - `` + "\n" + - `Requires replacement if changed. `, - }, - "target": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `JSON like target path for the attribute. Eg. last_name. Requires replacement if changed. ; Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "target_unique": schema.ListAttribute{ - Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, - Optional: true, - ElementType: types.StringType, - MarkdownDescription: `Array of keys which should be used when checking for uniqueness. Eg: [country, city, postal_code]` + "\n" + - `` + "\n" + - `Requires replacement if changed. `, - }, - "value_json": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - MarkdownDescription: `To be provided only when mapping json objects into a target attribute. Eg array of addresses.` + "\n" + - `` + "\n" + - `Requires replacement if changed. ; Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - Description: `Requires replacement if changed. `, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("copy_value_mapper"), - path.MatchRelative().AtParent().AtName("set_value_mapper"), - }...), - }, - }, - "copy_value_mapper": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "mode": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - MarkdownDescription: `- copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property.` + "\n" + - `` + "\n" + - `Requires replacement if changed. ; Not Null; must be one of ["copy_if_exists", "append_if_exists", "set_value"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "copy_if_exists", - "append_if_exists", - "set_value", - ), - }, - }, - "source": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - MarkdownDescription: `JSON source path for the value to be extracted from the main entity. Eg: steps[1].['Product Info'].price` + "\n" + - `` + "\n" + - `Requires replacement if changed. ; Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "target": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `JSON like target path for the attribute. Eg. last_name. Requires replacement if changed. ; Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - Description: `Requires replacement if changed. `, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("append_value_mapper"), - path.MatchRelative().AtParent().AtName("set_value_mapper"), - }...), - }, - }, - "set_value_mapper": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "mode": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - MarkdownDescription: `- copy_if_exists - it replaces the target attribute with the source value - append_if_exists - it currently replaces target attribute with array like values. Useful when you have multiple values to be added into one attribute. - set_value - it sets a value to a predefined value. Must be used together with value property.` + "\n" + - `` + "\n" + - `Requires replacement if changed. ; Not Null; must be one of ["copy_if_exists", "append_if_exists", "set_value"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "copy_if_exists", - "append_if_exists", - "set_value", - ), - }, - }, - "target": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `JSON like target path for the attribute. Eg. last_name. Requires replacement if changed. ; Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "value": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - MarkdownDescription: `Any value to be set: string, number, string[], number[], JSON object, etc. It will override existing values, if any.` + "\n" + - `` + "\n" + - `Parsed as JSON.`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - validators.IsValidJSON(), - }, - }, - }, - Description: `Requires replacement if changed. `, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("append_value_mapper"), - path.MatchRelative().AtParent().AtName("copy_value_mapper"), - }...), - }, - }, - }, - Description: `Requires replacement if changed. `, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("mapping_attribute_v2"), - }...), - validators.ExactlyOneChild(), - }, - }, - "mapping_attribute_v2": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "operation": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "any": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Parsed as JSON.`, - Validators: []validator.String{ - stringvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("operation_object_node"), - }...), - validators.IsValidJSON(), - }, - }, - "operation_object_node": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "append": schema.ListAttribute{ - Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, - Optional: true, - ElementType: types.StringType, - Description: `Append to array. Requires replacement if changed. `, - Validators: []validator.List{ - listvalidator.ValueStringsAre(validators.IsValidJSON()), - }, - }, - "copy": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Copy JSONPath value from source entity context. Requires replacement if changed. `, - }, - "random": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "one": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "type": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Requires replacement if changed. ; Not Null; must be one of ["uuid", "nanoid"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "uuid", - "nanoid", - ), - }, - }, - }, - Description: `Requires replacement if changed. `, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("two"), - }...), - }, - }, - "two": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "max": schema.NumberAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Number{ - numberplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_numberplanmodifier.SuppressDiff(speakeasy_numberplanmodifier.ExplicitSuppress), - }, - Optional: true, - Default: numberdefault.StaticBigFloat(big.NewFloat(1)), - Description: `Requires replacement if changed. ; Default: 1`, - }, - "min": schema.NumberAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Number{ - numberplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_numberplanmodifier.SuppressDiff(speakeasy_numberplanmodifier.ExplicitSuppress), - }, - Optional: true, - Default: numberdefault.StaticBigFloat(big.NewFloat(0)), - Description: `Requires replacement if changed. ; Default: 0`, - }, - "type": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Requires replacement if changed. ; Not Null; must be one of ["number"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "number", - ), - }, - }, - }, - Description: `Requires replacement if changed. `, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("one"), - }...), - }, - }, - }, - Description: `Requires replacement if changed. `, - Validators: []validator.Object{ - validators.ExactlyOneChild(), - }, - }, - "set": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Parsed as JSON.`, - Validators: []validator.String{ - validators.IsValidJSON(), - }, - }, - "template": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Define handlebars template to output a string. Requires replacement if changed. `, - }, - "uniq": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "boolean": schema.BoolAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_boolplanmodifier.SuppressDiff(speakeasy_boolplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Requires replacement if changed. `, - Validators: []validator.Bool{ - boolvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("array_of_str"), - }...), - }, - }, - "array_of_str": schema.ListAttribute{ - Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, - Optional: true, - ElementType: types.StringType, - Description: `Requires replacement if changed. `, - Validators: []validator.List{ - listvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("boolean"), - }...), - }, - }, - }, - Description: `Unique array. Requires replacement if changed. `, - Validators: []validator.Object{ - validators.ExactlyOneChild(), - }, - }, - "additional_properties": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Parsed as JSON.`, - Validators: []validator.String{ - validators.IsValidJSON(), - }, - }, - }, - Description: `Requires replacement if changed. `, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("any"), - }...), - }, - }, - }, - Description: `Mapping operation nodes are either primitive values or operation node objects. Requires replacement if changed. ; Not Null`, - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - validators.ExactlyOneChild(), - }, - }, - "origin": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Origin of an attribute. Requires replacement if changed. ; must be one of ["system_recommendation", "user_manually", "entity_updating_system_recommendation"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "system_recommendation", - "user_manually", - "entity_updating_system_recommendation", - ), - }, - }, - "target": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Target JSON path for the attribute to set. Requires replacement if changed. ; Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - Description: `Requires replacement if changed. `, - Validators: []validator.Object{ - objectvalidator.ConflictsWith(path.Expressions{ - path.MatchRelative().AtParent().AtName("mapping_attribute"), - }...), - }, - }, - }, - Validators: []validator.Object{ - validators.ExactlyOneChild(), - }, - }, - Description: `Attribute mappings. Requires replacement if changed. ; Not Null`, - Validators: []validator.List{ - speakeasy_listvalidators.NotNull(), - }, - }, - "name": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `A name for this configuration. Requires replacement if changed. `, - }, - "relation_attributes": schema.ListNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "mode": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Requires replacement if changed. ; Not Null; must be one of ["append", "prepend", "set"]`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - stringvalidator.OneOf( - "append", - "prepend", - "set", - ), - }, - }, - "origin": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Origin of an attribute. Requires replacement if changed. ; must be one of ["system_recommendation", "user_manually", "entity_updating_system_recommendation"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "system_recommendation", - "user_manually", - "entity_updating_system_recommendation", - ), - }, - }, - "related_to": schema.MapAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Map{ - mapplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_mapplanmodifier.SuppressDiff(speakeasy_mapplanmodifier.ExplicitSuppress), - }, - Optional: true, - ElementType: types.StringType, - Description: `Requires replacement if changed. `, - Validators: []validator.Map{ - mapvalidator.ValueStringsAre(validators.IsValidJSON()), - }, - }, - "source_filter": schema.SingleNestedAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_objectplanmodifier.SuppressDiff(speakeasy_objectplanmodifier.ExplicitSuppress), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "attribute": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Filter by a specific relation attribute on the main entity. Requires replacement if changed. `, - }, - "limit": schema.Int64Attribute{ - Computed: true, - PlanModifiers: []planmodifier.Int64{ - int64planmodifier.RequiresReplaceIfConfigured(), - speakeasy_int64planmodifier.SuppressDiff(speakeasy_int64planmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Limit relations to maximum number (default, all matched relations). Requires replacement if changed. `, - }, - "relation_tag": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Filter by relation tag (label) on the main entity. Requires replacement if changed. `, - }, - "schema": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Filter by specific schema. Requires replacement if changed. `, - }, - "self": schema.BoolAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_boolplanmodifier.SuppressDiff(speakeasy_boolplanmodifier.ExplicitSuppress), - }, - Optional: true, - Default: booldefault.StaticBool(false), - Description: `Picks main entity as relation (overrides other filters). Requires replacement if changed. ; Default: false`, - }, - "tag": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Filter by a specific tag on the related entity. Requires replacement if changed. `, - }, - }, - Description: `A filter to identify which source entities to pick as relations from main entity. Requires replacement if changed. `, - }, - "target": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Target attribute to store the relation in. Requires replacement if changed. ; Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "target_tags": schema.ListAttribute{ - Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, - Optional: true, - ElementType: types.StringType, - Description: `Relation tags (labels) to set for the stored relations. Requires replacement if changed. `, - }, - "target_tags_include_source": schema.BoolAttribute{ - Computed: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_boolplanmodifier.SuppressDiff(speakeasy_boolplanmodifier.ExplicitSuppress), - }, - Optional: true, - Default: booldefault.StaticBool(false), - Description: `Include all relation tags (labels) present on the main entity relation. Requires replacement if changed. ; Default: false`, - }, - }, - }, - Description: `Relation mappings. Requires replacement if changed. `, - }, - "target_schema": schema.StringAttribute{ - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), - }, - Optional: true, - Description: `Schema of target entity. Requires replacement if changed. ; Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "target_unique": schema.ListAttribute{ - Computed: true, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplaceIfConfigured(), - speakeasy_listplanmodifier.SuppressDiff(speakeasy_listplanmodifier.ExplicitSuppress), - }, - Optional: true, - ElementType: types.StringType, - Description: `Unique key for target entity (see upsertEntity of Entity API). Requires replacement if changed. `, - }, - }, + Required: true, + Description: `Parsed as JSON.`, + Validators: []validator.String{ + validators.IsValidJSON(), }, - Description: `Requires replacement if changed. `, }, }, } diff --git a/internal/provider/entitymapping_resource_sdk.go b/internal/provider/entitymapping_resource_sdk.go index bac77a9..a4f8c98 100644 --- a/internal/provider/entitymapping_resource_sdk.go +++ b/internal/provider/entitymapping_resource_sdk.go @@ -7,7 +7,6 @@ import ( tfTypes "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/provider/types" "github.com/epilot-dev/terraform-provider-epilot-entitymapping/internal/sdk/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" - "math/big" ) func (r *EntityMappingResourceModel) ToSharedMappingConfigV2() *shared.MappingConfigV2 { @@ -61,370 +60,8 @@ func (r *EntityMappingResourceModel) ToSharedMappingConfigV2() *shared.MappingCo Config: config, Type: typeVar, } - var targets []shared.TargetConfig = []shared.TargetConfig{} - for _, targetsItem := range r.Targets { - allowFailure := new(bool) - if !targetsItem.AllowFailure.IsUnknown() && !targetsItem.AllowFailure.IsNull() { - *allowFailure = targetsItem.AllowFailure.ValueBool() - } else { - allowFailure = nil - } - var conditionMode interface{} - if !targetsItem.ConditionMode.IsUnknown() && !targetsItem.ConditionMode.IsNull() { - _ = json.Unmarshal([]byte(targetsItem.ConditionMode.ValueString()), &conditionMode) - } - var conditions interface{} - if !targetsItem.Conditions.IsUnknown() && !targetsItem.Conditions.IsNull() { - _ = json.Unmarshal([]byte(targetsItem.Conditions.ValueString()), &conditions) - } - id1 := new(string) - if !targetsItem.ID.IsUnknown() && !targetsItem.ID.IsNull() { - *id1 = targetsItem.ID.ValueString() - } else { - id1 = nil - } - linkbackRelationAttribute := new(string) - if !targetsItem.LinkbackRelationAttribute.IsUnknown() && !targetsItem.LinkbackRelationAttribute.IsNull() { - *linkbackRelationAttribute = targetsItem.LinkbackRelationAttribute.ValueString() - } else { - linkbackRelationAttribute = nil - } - var linkbackRelationTags []string = []string{} - for _, linkbackRelationTagsItem := range targetsItem.LinkbackRelationTags { - linkbackRelationTags = append(linkbackRelationTags, linkbackRelationTagsItem.ValueString()) - } - var loopConfig *shared.LoopConfig - if targetsItem.LoopConfig != nil { - length := new(float64) - if !targetsItem.LoopConfig.Length.IsUnknown() && !targetsItem.LoopConfig.Length.IsNull() { - *length, _ = targetsItem.LoopConfig.Length.ValueBigFloat().Float64() - } else { - length = nil - } - sourcePath := new(string) - if !targetsItem.LoopConfig.SourcePath.IsUnknown() && !targetsItem.LoopConfig.SourcePath.IsNull() { - *sourcePath = targetsItem.LoopConfig.SourcePath.ValueString() - } else { - sourcePath = nil - } - loopConfig = &shared.LoopConfig{ - Length: length, - SourcePath: sourcePath, - } - } - var mappingAttributes []shared.MappingAttributes = []shared.MappingAttributes{} - for _, mappingAttributesItem := range targetsItem.MappingAttributes { - if mappingAttributesItem.MappingAttributeV2 != nil { - var operation shared.OperationNode - var operationObjectNode *shared.OperationObjectNode - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode != nil { - var additionalProperties interface{} - if !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties.IsUnknown() && !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties.IsNull() { - _ = json.Unmarshal([]byte(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties.ValueString()), &additionalProperties) - } - var append1 []interface{} = []interface{}{} - for _, appendItem := range mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Append { - var appendTmp interface{} - _ = json.Unmarshal([]byte(appendItem.ValueString()), &appendTmp) - append1 = append(append1, appendTmp) - } - copy := new(string) - if !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Copy.IsUnknown() && !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Copy.IsNull() { - *copy = mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Copy.ValueString() - } else { - copy = nil - } - var random *shared.RandomOperation - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random != nil { - var one *shared.One - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.One != nil { - typeVar1 := shared.RandomOperationSchemasType(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.One.Type.ValueString()) - one = &shared.One{ - Type: typeVar1, - } - } - if one != nil { - random = &shared.RandomOperation{ - One: one, - } - } - var two *shared.Two - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two != nil { - max := new(float64) - if !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max.IsUnknown() && !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max.IsNull() { - *max, _ = mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max.ValueBigFloat().Float64() - } else { - max = nil - } - min := new(float64) - if !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min.IsUnknown() && !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min.IsNull() { - *min, _ = mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min.ValueBigFloat().Float64() - } else { - min = nil - } - typeVar2 := shared.RandomOperationType(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Type.ValueString()) - two = &shared.Two{ - Max: max, - Min: min, - Type: typeVar2, - } - } - if two != nil { - random = &shared.RandomOperation{ - Two: two, - } - } - } - var set interface{} - if !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Set.IsUnknown() && !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Set.IsNull() { - _ = json.Unmarshal([]byte(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Set.ValueString()), &set) - } - template := new(string) - if !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Template.IsUnknown() && !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Template.IsNull() { - *template = mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Template.ValueString() - } else { - template = nil - } - var uniq *shared.Uniq - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq != nil { - boolean := new(bool) - if !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.Boolean.IsUnknown() && !mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.Boolean.IsNull() { - *boolean = mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.Boolean.ValueBool() - } else { - boolean = nil - } - if boolean != nil { - uniq = &shared.Uniq{ - Boolean: boolean, - } - } - var arrayOfStr []string = []string{} - for _, arrayOfStrItem := range mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr { - arrayOfStr = append(arrayOfStr, arrayOfStrItem.ValueString()) - } - if arrayOfStr != nil { - uniq = &shared.Uniq{ - ArrayOfStr: arrayOfStr, - } - } - } - operationObjectNode = &shared.OperationObjectNode{ - AdditionalProperties: additionalProperties, - Append: append1, - Copy: copy, - Random: random, - Set: set, - Template: template, - Uniq: uniq, - } - } - if operationObjectNode != nil { - operation = shared.OperationNode{ - OperationObjectNode: operationObjectNode, - } - } - var anyVar interface{} - if !mappingAttributesItem.MappingAttributeV2.Operation.Any.IsUnknown() && !mappingAttributesItem.MappingAttributeV2.Operation.Any.IsNull() { - _ = json.Unmarshal([]byte(mappingAttributesItem.MappingAttributeV2.Operation.Any.ValueString()), &anyVar) - } - if anyVar != nil { - operation = shared.OperationNode{ - Any: anyVar, - } - } - origin := new(shared.AttributeOrigin) - if !mappingAttributesItem.MappingAttributeV2.Origin.IsUnknown() && !mappingAttributesItem.MappingAttributeV2.Origin.IsNull() { - *origin = shared.AttributeOrigin(mappingAttributesItem.MappingAttributeV2.Origin.ValueString()) - } else { - origin = nil - } - target := mappingAttributesItem.MappingAttributeV2.Target.ValueString() - mappingAttributeV2 := shared.MappingAttributeV2{ - Operation: operation, - Origin: origin, - Target: target, - } - mappingAttributes = append(mappingAttributes, shared.MappingAttributes{ - MappingAttributeV2: &mappingAttributeV2, - }) - } - if mappingAttributesItem.MappingAttribute != nil { - var mappingAttribute shared.MappingAttribute - var setValueMapper *shared.SetValueMapper - if mappingAttributesItem.MappingAttribute.SetValueMapper != nil { - mode := shared.MappingAttributeMode(mappingAttributesItem.MappingAttribute.SetValueMapper.Mode.ValueString()) - target1 := mappingAttributesItem.MappingAttribute.SetValueMapper.Target.ValueString() - var value interface{} - _ = json.Unmarshal([]byte(mappingAttributesItem.MappingAttribute.SetValueMapper.Value.ValueString()), &value) - setValueMapper = &shared.SetValueMapper{ - Mode: mode, - Target: target1, - Value: value, - } - } - if setValueMapper != nil { - mappingAttribute = shared.MappingAttribute{ - SetValueMapper: setValueMapper, - } - } - var copyValueMapper *shared.CopyValueMapper - if mappingAttributesItem.MappingAttribute.CopyValueMapper != nil { - mode1 := shared.MappingAttributeMode(mappingAttributesItem.MappingAttribute.CopyValueMapper.Mode.ValueString()) - source1 := mappingAttributesItem.MappingAttribute.CopyValueMapper.Source.ValueString() - target2 := mappingAttributesItem.MappingAttribute.CopyValueMapper.Target.ValueString() - copyValueMapper = &shared.CopyValueMapper{ - Mode: mode1, - Source: source1, - Target: target2, - } - } - if copyValueMapper != nil { - mappingAttribute = shared.MappingAttribute{ - CopyValueMapper: copyValueMapper, - } - } - var appendValueMapper *shared.AppendValueMapper - if mappingAttributesItem.MappingAttribute.AppendValueMapper != nil { - mode2 := shared.MappingAttributeMode(mappingAttributesItem.MappingAttribute.AppendValueMapper.Mode.ValueString()) - source2 := new(string) - if !mappingAttributesItem.MappingAttribute.AppendValueMapper.Source.IsUnknown() && !mappingAttributesItem.MappingAttribute.AppendValueMapper.Source.IsNull() { - *source2 = mappingAttributesItem.MappingAttribute.AppendValueMapper.Source.ValueString() - } else { - source2 = nil - } - target3 := mappingAttributesItem.MappingAttribute.AppendValueMapper.Target.ValueString() - var targetUnique []string = []string{} - for _, targetUniqueItem := range mappingAttributesItem.MappingAttribute.AppendValueMapper.TargetUnique { - targetUnique = append(targetUnique, targetUniqueItem.ValueString()) - } - valueJSON := mappingAttributesItem.MappingAttribute.AppendValueMapper.ValueJSON.ValueString() - appendValueMapper = &shared.AppendValueMapper{ - Mode: mode2, - Source: source2, - Target: target3, - TargetUnique: targetUnique, - ValueJSON: valueJSON, - } - } - if appendValueMapper != nil { - mappingAttribute = shared.MappingAttribute{ - AppendValueMapper: appendValueMapper, - } - } - mappingAttributes = append(mappingAttributes, shared.MappingAttributes{ - MappingAttribute: &mappingAttribute, - }) - } - } - name := new(string) - if !targetsItem.Name.IsUnknown() && !targetsItem.Name.IsNull() { - *name = targetsItem.Name.ValueString() - } else { - name = nil - } - var relationAttributes []shared.RelationAttribute = []shared.RelationAttribute{} - for _, relationAttributesItem := range targetsItem.RelationAttributes { - mode3 := shared.Mode(relationAttributesItem.Mode.ValueString()) - origin1 := new(shared.AttributeOrigin) - if !relationAttributesItem.Origin.IsUnknown() && !relationAttributesItem.Origin.IsNull() { - *origin1 = shared.AttributeOrigin(relationAttributesItem.Origin.ValueString()) - } else { - origin1 = nil - } - relatedTo := make(map[string]interface{}) - for relatedToKey, relatedToValue := range relationAttributesItem.RelatedTo { - var relatedToInst interface{} - _ = json.Unmarshal([]byte(relatedToValue.ValueString()), &relatedToInst) - relatedTo[relatedToKey] = relatedToInst - } - var sourceFilter *shared.SourceFilter - if relationAttributesItem.SourceFilter != nil { - attribute := new(string) - if !relationAttributesItem.SourceFilter.Attribute.IsUnknown() && !relationAttributesItem.SourceFilter.Attribute.IsNull() { - *attribute = relationAttributesItem.SourceFilter.Attribute.ValueString() - } else { - attribute = nil - } - limit := new(int64) - if !relationAttributesItem.SourceFilter.Limit.IsUnknown() && !relationAttributesItem.SourceFilter.Limit.IsNull() { - *limit = relationAttributesItem.SourceFilter.Limit.ValueInt64() - } else { - limit = nil - } - relationTag := new(string) - if !relationAttributesItem.SourceFilter.RelationTag.IsUnknown() && !relationAttributesItem.SourceFilter.RelationTag.IsNull() { - *relationTag = relationAttributesItem.SourceFilter.RelationTag.ValueString() - } else { - relationTag = nil - } - schema := new(string) - if !relationAttributesItem.SourceFilter.Schema.IsUnknown() && !relationAttributesItem.SourceFilter.Schema.IsNull() { - *schema = relationAttributesItem.SourceFilter.Schema.ValueString() - } else { - schema = nil - } - self := new(bool) - if !relationAttributesItem.SourceFilter.Self.IsUnknown() && !relationAttributesItem.SourceFilter.Self.IsNull() { - *self = relationAttributesItem.SourceFilter.Self.ValueBool() - } else { - self = nil - } - tag := new(string) - if !relationAttributesItem.SourceFilter.Tag.IsUnknown() && !relationAttributesItem.SourceFilter.Tag.IsNull() { - *tag = relationAttributesItem.SourceFilter.Tag.ValueString() - } else { - tag = nil - } - sourceFilter = &shared.SourceFilter{ - Attribute: attribute, - Limit: limit, - RelationTag: relationTag, - Schema: schema, - Self: self, - Tag: tag, - } - } - target4 := relationAttributesItem.Target.ValueString() - var targetTags []string = []string{} - for _, targetTagsItem := range relationAttributesItem.TargetTags { - targetTags = append(targetTags, targetTagsItem.ValueString()) - } - targetTagsIncludeSource := new(bool) - if !relationAttributesItem.TargetTagsIncludeSource.IsUnknown() && !relationAttributesItem.TargetTagsIncludeSource.IsNull() { - *targetTagsIncludeSource = relationAttributesItem.TargetTagsIncludeSource.ValueBool() - } else { - targetTagsIncludeSource = nil - } - relationAttributes = append(relationAttributes, shared.RelationAttribute{ - Mode: mode3, - Origin: origin1, - RelatedTo: relatedTo, - SourceFilter: sourceFilter, - Target: target4, - TargetTags: targetTags, - TargetTagsIncludeSource: targetTagsIncludeSource, - }) - } - targetSchema := targetsItem.TargetSchema.ValueString() - var targetUnique1 []string = []string{} - for _, targetUniqueItem1 := range targetsItem.TargetUnique { - targetUnique1 = append(targetUnique1, targetUniqueItem1.ValueString()) - } - targets = append(targets, shared.TargetConfig{ - AllowFailure: allowFailure, - ConditionMode: conditionMode, - Conditions: conditions, - ID: id1, - LinkbackRelationAttribute: linkbackRelationAttribute, - LinkbackRelationTags: linkbackRelationTags, - LoopConfig: loopConfig, - MappingAttributes: mappingAttributes, - Name: name, - RelationAttributes: relationAttributes, - TargetSchema: targetSchema, - TargetUnique: targetUnique1, - }) - } + var targets interface{} + _ = json.Unmarshal([]byte(r.Targets.ValueString()), &targets) out := shared.MappingConfigV2{ ID: id, Source: source, @@ -455,220 +92,7 @@ func (r *EntityMappingResourceModel) RefreshFromSharedMappingConfigV2(resp *shar } else { r.Source.Type = types.StringNull() } - r.Targets = []tfTypes.TargetConfig{} - if len(r.Targets) > len(resp.Targets) { - r.Targets = r.Targets[:len(resp.Targets)] - } - for targetsCount, targetsItem := range resp.Targets { - var targets1 tfTypes.TargetConfig - targets1.AllowFailure = types.BoolPointerValue(targetsItem.AllowFailure) - if targetsItem.ConditionMode == nil { - targets1.ConditionMode = types.StringNull() - } else { - conditionModeResult, _ := json.Marshal(targetsItem.ConditionMode) - targets1.ConditionMode = types.StringValue(string(conditionModeResult)) - } - if targetsItem.Conditions == nil { - targets1.Conditions = types.StringNull() - } else { - conditionsResult, _ := json.Marshal(targetsItem.Conditions) - targets1.Conditions = types.StringValue(string(conditionsResult)) - } - targets1.ID = types.StringPointerValue(targetsItem.ID) - targets1.LinkbackRelationAttribute = types.StringPointerValue(targetsItem.LinkbackRelationAttribute) - targets1.LinkbackRelationTags = []types.String{} - for _, v := range targetsItem.LinkbackRelationTags { - targets1.LinkbackRelationTags = append(targets1.LinkbackRelationTags, types.StringValue(v)) - } - if targetsItem.LoopConfig == nil { - targets1.LoopConfig = nil - } else { - targets1.LoopConfig = &tfTypes.LoopConfig{} - if targetsItem.LoopConfig.Length != nil { - targets1.LoopConfig.Length = types.NumberValue(big.NewFloat(float64(*targetsItem.LoopConfig.Length))) - } else { - targets1.LoopConfig.Length = types.NumberNull() - } - targets1.LoopConfig.SourcePath = types.StringPointerValue(targetsItem.LoopConfig.SourcePath) - } - targets1.MappingAttributes = []tfTypes.MappingAttributes{} - for mappingAttributesCount, mappingAttributesItem := range targetsItem.MappingAttributes { - var mappingAttributes1 tfTypes.MappingAttributes - if mappingAttributesItem.MappingAttribute != nil { - mappingAttributes1.MappingAttribute = &tfTypes.MappingAttribute{} - if mappingAttributesItem.MappingAttribute.AppendValueMapper != nil { - mappingAttributes1.MappingAttribute.AppendValueMapper = &tfTypes.AppendValueMapper{} - mappingAttributes1.MappingAttribute.AppendValueMapper.Mode = types.StringValue(string(mappingAttributesItem.MappingAttribute.AppendValueMapper.Mode)) - mappingAttributes1.MappingAttribute.AppendValueMapper.Source = types.StringPointerValue(mappingAttributesItem.MappingAttribute.AppendValueMapper.Source) - mappingAttributes1.MappingAttribute.AppendValueMapper.Target = types.StringValue(mappingAttributesItem.MappingAttribute.AppendValueMapper.Target) - mappingAttributes1.MappingAttribute.AppendValueMapper.TargetUnique = []types.String{} - for _, v := range mappingAttributesItem.MappingAttribute.AppendValueMapper.TargetUnique { - mappingAttributes1.MappingAttribute.AppendValueMapper.TargetUnique = append(mappingAttributes1.MappingAttribute.AppendValueMapper.TargetUnique, types.StringValue(v)) - } - mappingAttributes1.MappingAttribute.AppendValueMapper.ValueJSON = types.StringValue(mappingAttributesItem.MappingAttribute.AppendValueMapper.ValueJSON) - } - if mappingAttributesItem.MappingAttribute.CopyValueMapper != nil { - mappingAttributes1.MappingAttribute.CopyValueMapper = &tfTypes.CopyValueMapper{} - mappingAttributes1.MappingAttribute.CopyValueMapper.Mode = types.StringValue(string(mappingAttributesItem.MappingAttribute.CopyValueMapper.Mode)) - mappingAttributes1.MappingAttribute.CopyValueMapper.Source = types.StringValue(mappingAttributesItem.MappingAttribute.CopyValueMapper.Source) - mappingAttributes1.MappingAttribute.CopyValueMapper.Target = types.StringValue(mappingAttributesItem.MappingAttribute.CopyValueMapper.Target) - } - if mappingAttributesItem.MappingAttribute.SetValueMapper != nil { - mappingAttributes1.MappingAttribute.SetValueMapper = &tfTypes.SetValueMapper{} - mappingAttributes1.MappingAttribute.SetValueMapper.Mode = types.StringValue(string(mappingAttributesItem.MappingAttribute.SetValueMapper.Mode)) - mappingAttributes1.MappingAttribute.SetValueMapper.Target = types.StringValue(mappingAttributesItem.MappingAttribute.SetValueMapper.Target) - valueResult, _ := json.Marshal(mappingAttributesItem.MappingAttribute.SetValueMapper.Value) - mappingAttributes1.MappingAttribute.SetValueMapper.Value = types.StringValue(string(valueResult)) - } - } - if mappingAttributesItem.MappingAttributeV2 != nil { - mappingAttributes1.MappingAttributeV2 = &tfTypes.MappingAttributeV2{} - if mappingAttributesItem.MappingAttributeV2.Operation.Any != nil { - anyResult, _ := json.Marshal(mappingAttributesItem.MappingAttributeV2.Operation.Any) - mappingAttributes1.MappingAttributeV2.Operation.Any = types.StringValue(string(anyResult)) - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode = &tfTypes.OperationObjectNode{} - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Append = nil - for _, appendItem := range mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Append { - var append2 types.String - append2Result, _ := json.Marshal(appendItem) - append2 = types.StringValue(string(append2Result)) - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Append = append(mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Append, append2) - } - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Copy = types.StringPointerValue(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Copy) - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random == nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random = nil - } else { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random = &tfTypes.RandomOperation{} - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.One != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.One = &tfTypes.One{} - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.One.Type = types.StringValue(string(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.One.Type)) - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two = &tfTypes.Two{} - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max = types.NumberValue(big.NewFloat(float64(*mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max))) - } else { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Max = types.NumberNull() - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min = types.NumberValue(big.NewFloat(float64(*mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min))) - } else { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Min = types.NumberNull() - } - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Type = types.StringValue(string(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Random.Two.Type)) - } - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Set == nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Set = types.StringNull() - } else { - setResult, _ := json.Marshal(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Set) - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Set = types.StringValue(string(setResult)) - } - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Template = types.StringPointerValue(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Template) - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq == nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq = nil - } else { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq = &tfTypes.Uniq{} - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.Boolean != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq.Boolean = types.BoolPointerValue(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.Boolean) - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr != nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr = []types.String{} - for _, v := range mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr = append(mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.Uniq.ArrayOfStr, types.StringValue(v)) - } - } - } - if mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties == nil { - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties = types.StringNull() - } else { - additionalPropertiesResult, _ := json.Marshal(mappingAttributesItem.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties) - mappingAttributes1.MappingAttributeV2.Operation.OperationObjectNode.AdditionalProperties = types.StringValue(string(additionalPropertiesResult)) - } - } - if mappingAttributesItem.MappingAttributeV2.Origin != nil { - mappingAttributes1.MappingAttributeV2.Origin = types.StringValue(string(*mappingAttributesItem.MappingAttributeV2.Origin)) - } else { - mappingAttributes1.MappingAttributeV2.Origin = types.StringNull() - } - mappingAttributes1.MappingAttributeV2.Target = types.StringValue(mappingAttributesItem.MappingAttributeV2.Target) - } - if mappingAttributesCount+1 > len(targets1.MappingAttributes) { - targets1.MappingAttributes = append(targets1.MappingAttributes, mappingAttributes1) - } else { - targets1.MappingAttributes[mappingAttributesCount].MappingAttribute = mappingAttributes1.MappingAttribute - targets1.MappingAttributes[mappingAttributesCount].MappingAttributeV2 = mappingAttributes1.MappingAttributeV2 - } - } - targets1.Name = types.StringPointerValue(targetsItem.Name) - targets1.RelationAttributes = []tfTypes.RelationAttribute{} - for relationAttributesCount, relationAttributesItem := range targetsItem.RelationAttributes { - var relationAttributes1 tfTypes.RelationAttribute - relationAttributes1.Mode = types.StringValue(string(relationAttributesItem.Mode)) - if relationAttributesItem.Origin != nil { - relationAttributes1.Origin = types.StringValue(string(*relationAttributesItem.Origin)) - } else { - relationAttributes1.Origin = types.StringNull() - } - if len(relationAttributesItem.RelatedTo) > 0 { - relationAttributes1.RelatedTo = make(map[string]types.String) - for key, value1 := range relationAttributesItem.RelatedTo { - result, _ := json.Marshal(value1) - relationAttributes1.RelatedTo[key] = types.StringValue(string(result)) - } - } - if relationAttributesItem.SourceFilter == nil { - relationAttributes1.SourceFilter = nil - } else { - relationAttributes1.SourceFilter = &tfTypes.SourceFilter{} - relationAttributes1.SourceFilter.Attribute = types.StringPointerValue(relationAttributesItem.SourceFilter.Attribute) - relationAttributes1.SourceFilter.Limit = types.Int64PointerValue(relationAttributesItem.SourceFilter.Limit) - relationAttributes1.SourceFilter.RelationTag = types.StringPointerValue(relationAttributesItem.SourceFilter.RelationTag) - relationAttributes1.SourceFilter.Schema = types.StringPointerValue(relationAttributesItem.SourceFilter.Schema) - relationAttributes1.SourceFilter.Self = types.BoolPointerValue(relationAttributesItem.SourceFilter.Self) - relationAttributes1.SourceFilter.Tag = types.StringPointerValue(relationAttributesItem.SourceFilter.Tag) - } - relationAttributes1.Target = types.StringValue(relationAttributesItem.Target) - relationAttributes1.TargetTags = []types.String{} - for _, v := range relationAttributesItem.TargetTags { - relationAttributes1.TargetTags = append(relationAttributes1.TargetTags, types.StringValue(v)) - } - relationAttributes1.TargetTagsIncludeSource = types.BoolPointerValue(relationAttributesItem.TargetTagsIncludeSource) - if relationAttributesCount+1 > len(targets1.RelationAttributes) { - targets1.RelationAttributes = append(targets1.RelationAttributes, relationAttributes1) - } else { - targets1.RelationAttributes[relationAttributesCount].Mode = relationAttributes1.Mode - targets1.RelationAttributes[relationAttributesCount].Origin = relationAttributes1.Origin - targets1.RelationAttributes[relationAttributesCount].RelatedTo = relationAttributes1.RelatedTo - targets1.RelationAttributes[relationAttributesCount].SourceFilter = relationAttributes1.SourceFilter - targets1.RelationAttributes[relationAttributesCount].Target = relationAttributes1.Target - targets1.RelationAttributes[relationAttributesCount].TargetTags = relationAttributes1.TargetTags - targets1.RelationAttributes[relationAttributesCount].TargetTagsIncludeSource = relationAttributes1.TargetTagsIncludeSource - } - } - targets1.TargetSchema = types.StringValue(targetsItem.TargetSchema) - targets1.TargetUnique = []types.String{} - for _, v := range targetsItem.TargetUnique { - targets1.TargetUnique = append(targets1.TargetUnique, types.StringValue(v)) - } - if targetsCount+1 > len(r.Targets) { - r.Targets = append(r.Targets, targets1) - } else { - r.Targets[targetsCount].AllowFailure = targets1.AllowFailure - r.Targets[targetsCount].ConditionMode = targets1.ConditionMode - r.Targets[targetsCount].Conditions = targets1.Conditions - r.Targets[targetsCount].ID = targets1.ID - r.Targets[targetsCount].LinkbackRelationAttribute = targets1.LinkbackRelationAttribute - r.Targets[targetsCount].LinkbackRelationTags = targets1.LinkbackRelationTags - r.Targets[targetsCount].LoopConfig = targets1.LoopConfig - r.Targets[targetsCount].MappingAttributes = targets1.MappingAttributes - r.Targets[targetsCount].Name = targets1.Name - r.Targets[targetsCount].RelationAttributes = targets1.RelationAttributes - r.Targets[targetsCount].TargetSchema = targets1.TargetSchema - r.Targets[targetsCount].TargetUnique = targets1.TargetUnique - } - } + targetsResult, _ := json.Marshal(resp.Targets) + r.Targets = types.StringValue(string(targetsResult)) } } diff --git a/internal/provider/types/append_value_mapper.go b/internal/provider/types/append_value_mapper.go deleted file mode 100644 index 9065deb..0000000 --- a/internal/provider/types/append_value_mapper.go +++ /dev/null @@ -1,13 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type AppendValueMapper struct { - Mode types.String `tfsdk:"mode"` - Source types.String `tfsdk:"source"` - Target types.String `tfsdk:"target"` - TargetUnique []types.String `tfsdk:"target_unique"` - ValueJSON types.String `tfsdk:"value_json"` -} diff --git a/internal/provider/types/copy_value_mapper.go b/internal/provider/types/copy_value_mapper.go deleted file mode 100644 index 8683413..0000000 --- a/internal/provider/types/copy_value_mapper.go +++ /dev/null @@ -1,11 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type CopyValueMapper struct { - Mode types.String `tfsdk:"mode"` - Source types.String `tfsdk:"source"` - Target types.String `tfsdk:"target"` -} diff --git a/internal/provider/types/loop_config.go b/internal/provider/types/loop_config.go deleted file mode 100644 index 7427e59..0000000 --- a/internal/provider/types/loop_config.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type LoopConfig struct { - Length types.Number `tfsdk:"length"` - SourcePath types.String `tfsdk:"source_path"` -} diff --git a/internal/provider/types/mapping_attribute.go b/internal/provider/types/mapping_attribute.go deleted file mode 100644 index f3ef68e..0000000 --- a/internal/provider/types/mapping_attribute.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -type MappingAttribute struct { - AppendValueMapper *AppendValueMapper `tfsdk:"append_value_mapper" tfPlanOnly:"true"` - CopyValueMapper *CopyValueMapper `tfsdk:"copy_value_mapper" tfPlanOnly:"true"` - SetValueMapper *SetValueMapper `tfsdk:"set_value_mapper" tfPlanOnly:"true"` -} diff --git a/internal/provider/types/mapping_attribute_v2.go b/internal/provider/types/mapping_attribute_v2.go deleted file mode 100644 index a490daf..0000000 --- a/internal/provider/types/mapping_attribute_v2.go +++ /dev/null @@ -1,11 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type MappingAttributeV2 struct { - Operation OperationNode `tfsdk:"operation"` - Origin types.String `tfsdk:"origin"` - Target types.String `tfsdk:"target"` -} diff --git a/internal/provider/types/mapping_attributes.go b/internal/provider/types/mapping_attributes.go deleted file mode 100644 index ba7ed6d..0000000 --- a/internal/provider/types/mapping_attributes.go +++ /dev/null @@ -1,8 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -type MappingAttributes struct { - MappingAttribute *MappingAttribute `tfsdk:"mapping_attribute" tfPlanOnly:"true"` - MappingAttributeV2 *MappingAttributeV2 `tfsdk:"mapping_attribute_v2" tfPlanOnly:"true"` -} diff --git a/internal/provider/types/one.go b/internal/provider/types/one.go deleted file mode 100644 index a477c47..0000000 --- a/internal/provider/types/one.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type One struct { - Type types.String `tfsdk:"type"` -} diff --git a/internal/provider/types/operation_node.go b/internal/provider/types/operation_node.go deleted file mode 100644 index ae1fec3..0000000 --- a/internal/provider/types/operation_node.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type OperationNode struct { - Any types.String `tfsdk:"any" tfPlanOnly:"true"` - OperationObjectNode *OperationObjectNode `tfsdk:"operation_object_node" tfPlanOnly:"true"` -} diff --git a/internal/provider/types/operation_object_node.go b/internal/provider/types/operation_object_node.go deleted file mode 100644 index 32deded..0000000 --- a/internal/provider/types/operation_object_node.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type OperationObjectNode struct { - Append []types.String `tfsdk:"append"` - Copy types.String `tfsdk:"copy"` - Random *RandomOperation `tfsdk:"random"` - Set types.String `tfsdk:"set"` - Template types.String `tfsdk:"template"` - Uniq *Uniq `tfsdk:"uniq"` - AdditionalProperties types.String `tfsdk:"additional_properties"` -} diff --git a/internal/provider/types/random_operation.go b/internal/provider/types/random_operation.go deleted file mode 100644 index 939eec8..0000000 --- a/internal/provider/types/random_operation.go +++ /dev/null @@ -1,8 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -type RandomOperation struct { - One *One `tfsdk:"one" tfPlanOnly:"true"` - Two *Two `tfsdk:"two" tfPlanOnly:"true"` -} diff --git a/internal/provider/types/relation_attribute.go b/internal/provider/types/relation_attribute.go deleted file mode 100644 index e546676..0000000 --- a/internal/provider/types/relation_attribute.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type RelationAttribute struct { - Mode types.String `tfsdk:"mode"` - Origin types.String `tfsdk:"origin"` - RelatedTo map[string]types.String `tfsdk:"related_to"` - SourceFilter *SourceFilter `tfsdk:"source_filter"` - Target types.String `tfsdk:"target"` - TargetTags []types.String `tfsdk:"target_tags"` - TargetTagsIncludeSource types.Bool `tfsdk:"target_tags_include_source"` -} diff --git a/internal/provider/types/set_value_mapper.go b/internal/provider/types/set_value_mapper.go deleted file mode 100644 index b5ddf94..0000000 --- a/internal/provider/types/set_value_mapper.go +++ /dev/null @@ -1,11 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type SetValueMapper struct { - Mode types.String `tfsdk:"mode"` - Target types.String `tfsdk:"target"` - Value types.String `tfsdk:"value"` -} diff --git a/internal/provider/types/source_filter.go b/internal/provider/types/source_filter.go deleted file mode 100644 index e5bed8d..0000000 --- a/internal/provider/types/source_filter.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type SourceFilter struct { - Attribute types.String `tfsdk:"attribute"` - Limit types.Int64 `tfsdk:"limit"` - RelationTag types.String `tfsdk:"relation_tag"` - Schema types.String `tfsdk:"schema"` - Self types.Bool `tfsdk:"self"` - Tag types.String `tfsdk:"tag"` -} diff --git a/internal/provider/types/target_config.go b/internal/provider/types/target_config.go deleted file mode 100644 index 4997e58..0000000 --- a/internal/provider/types/target_config.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type TargetConfig struct { - AllowFailure types.Bool `tfsdk:"allow_failure"` - ConditionMode types.String `tfsdk:"condition_mode"` - Conditions types.String `tfsdk:"conditions"` - ID types.String `tfsdk:"id"` - LinkbackRelationAttribute types.String `tfsdk:"linkback_relation_attribute"` - LinkbackRelationTags []types.String `tfsdk:"linkback_relation_tags"` - LoopConfig *LoopConfig `tfsdk:"loop_config"` - MappingAttributes []MappingAttributes `tfsdk:"mapping_attributes"` - Name types.String `tfsdk:"name"` - RelationAttributes []RelationAttribute `tfsdk:"relation_attributes"` - TargetSchema types.String `tfsdk:"target_schema"` - TargetUnique []types.String `tfsdk:"target_unique"` -} diff --git a/internal/provider/types/two.go b/internal/provider/types/two.go deleted file mode 100644 index 3238b5a..0000000 --- a/internal/provider/types/two.go +++ /dev/null @@ -1,11 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type Two struct { - Max types.Number `tfsdk:"max"` - Min types.Number `tfsdk:"min"` - Type types.String `tfsdk:"type"` -} diff --git a/internal/provider/types/uniq.go b/internal/provider/types/uniq.go deleted file mode 100644 index 75e3ce4..0000000 --- a/internal/provider/types/uniq.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.com). DO NOT EDIT. - -package types - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type Uniq struct { - Boolean types.Bool `tfsdk:"boolean" tfPlanOnly:"true"` - ArrayOfStr []types.String `tfsdk:"array_of_str" tfPlanOnly:"true"` -} diff --git a/internal/sdk/models/shared/mappingconfig.go b/internal/sdk/models/shared/mappingconfig.go index d5055ad..239341f 100644 --- a/internal/sdk/models/shared/mappingconfig.go +++ b/internal/sdk/models/shared/mappingconfig.go @@ -3,11 +3,11 @@ package shared type MappingConfig struct { - ID string `json:"id"` - OrgID string `json:"org_id"` - Source SourceConfig `json:"source"` - Targets []TargetConfig `json:"targets"` - Version int64 `json:"version"` + ID string `json:"id"` + OrgID string `json:"org_id"` + Source SourceConfig `json:"source"` + Targets any `json:"targets"` + Version int64 `json:"version"` } func (o *MappingConfig) GetID() string { @@ -31,9 +31,9 @@ func (o *MappingConfig) GetSource() SourceConfig { return o.Source } -func (o *MappingConfig) GetTargets() []TargetConfig { +func (o *MappingConfig) GetTargets() any { if o == nil { - return []TargetConfig{} + return nil } return o.Targets } diff --git a/internal/sdk/models/shared/mappingconfigv2.go b/internal/sdk/models/shared/mappingconfigv2.go index 46edad5..c9226c4 100644 --- a/internal/sdk/models/shared/mappingconfigv2.go +++ b/internal/sdk/models/shared/mappingconfigv2.go @@ -3,9 +3,9 @@ package shared type MappingConfigV2 struct { - ID string `json:"id"` - Source SourceConfig `json:"source"` - Targets []TargetConfig `json:"targets"` + ID string `json:"id"` + Source SourceConfig `json:"source"` + Targets any `json:"targets"` } func (o *MappingConfigV2) GetID() string { @@ -22,9 +22,9 @@ func (o *MappingConfigV2) GetSource() SourceConfig { return o.Source } -func (o *MappingConfigV2) GetTargets() []TargetConfig { +func (o *MappingConfigV2) GetTargets() any { if o == nil { - return []TargetConfig{} + return nil } return o.Targets } diff --git a/overlay.yaml b/overlay.yaml index 0d20d76..6c95144 100644 --- a/overlay.yaml +++ b/overlay.yaml @@ -42,16 +42,22 @@ actions: - target: $["components"]["schemas"] update: PrimitiveJSONValue: {} - - target: $["components"]["schemas"]["TargetConfig"]["properties"]["conditionMode"] - remove: true - - target: $["components"]["schemas"]["TargetConfig"]["properties"] - update: - conditionMode: {} - target: $["components"]["schemas"]["Entity"] remove: true - target: $["components"]["schemas"] update: Entity: {} + # No need to typing target blocks, a jsonencode for targets will be faster + - target: $["components"]["schemas"]["MappingConfigCommonFields"]["properties"]["targets"] + remove: true + - target: $["components"]["schemas"]["MappingConfigCommonFields"]["properties"] + update: + targets: {} + - target: $["components"]["schemas"]["TargetConfig"]["properties"]["conditionMode"] + remove: true + - target: $["components"]["schemas"]["TargetConfig"]["properties"] + update: + conditionMode: {} - target: $["components"]["schemas"]["TargetConfig"]["properties"]["conditions"] remove: true - target: $["components"]["schemas"]["TargetConfig"]["properties"]