Skip to content

Commit

Permalink
jsonencode logics
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishu Goel committed Sep 23, 2024
1 parent c481c36 commit 31e3b8c
Show file tree
Hide file tree
Showing 20 changed files with 180 additions and 219 deletions.
15 changes: 7 additions & 8 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
lockVersion: 2.0.0
id: 1afd37bc-cea9-4679-ac40-35ad5de414fc
management:
docChecksum: df07a1414838ec1c3035cc68f0a2f119
docChecksum: 0e536dabf767327b63b4963c5df07654
docVersion: 1.0.0
speakeasyVersion: 1.393.2
generationVersion: 2.413.0
releaseVersion: 0.5.1
configChecksum: 65e21fddd4b20ebd767c1d1cb13406f9
speakeasyVersion: 1.401.3
generationVersion: 2.421.3
releaseVersion: 0.5.2
configChecksum: e27f5aa24995ecaf812736d1da66d22a
repoURL: https://github.com/epilot-dev/terraform-provider-epilot-journey.git
repoSubDirectory: .
published: true
Expand All @@ -15,7 +15,7 @@ features:
additionalDependencies: 0.1.0
additionalProperties: 0.1.2
constsAndDefaults: 0.1.4
core: 3.24.9
core: 3.24.12
deprecations: 2.81.1
envVarSecurityUsage: 0.1.0
globalSecurity: 2.81.8
Expand Down Expand Up @@ -67,7 +67,6 @@ generatedFiles:
- internal/provider/types/journey_creation_request_v2_context_schema.go
- internal/provider/types/journey_creation_request_v2_design.go
- internal/provider/types/journey_creation_request_v2_embed_options.go
- internal/provider/types/journey_creation_request_v2_logics.go
- internal/provider/types/journey_creation_request_v2_rules.go
- internal/provider/types/journey_creation_request_v2_settings.go
- internal/provider/utils.go
Expand Down Expand Up @@ -155,7 +154,7 @@ examples:
application/json: {"file_id": "1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p", "language": "de"}
responses:
"200":
application/json: {"docx_output": {"output_document": {"filename": "my-template-OR-001.docx", "s3ref": {"bucket": "document-api-preview-prod", "key": "preview/my-template.docx"}}, "preview_url": "https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.docx"}, "pdf_output": {"output_document": {"filename": "my-template-OR-001.pdf", "s3ref": {"bucket": "document-api-preview-prod", "key": "preview/my-template.pdf"}}, "preview_url": "https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.pdf"}, "template_settings": {"custom_margins": {"bottom": 2.54, "top": 2.54}, "display_margin_guidelines": true, "enable_data_table_margin_autofix": false, "enabled_template_settings_persistence": false, "file_entity_id": "1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p", "misconfigured_margins": false, "suggested_margins": {"bottom": 2.54, "top": 2.54}, "template_with_datatable": false}}
application/json: {"docx_output": {"output_document": {"filename": "my-template-OR-001.docx", "s3ref": {"bucket": "document-api-prod", "key": "uploads/my-template.pdf"}}, "preview_url": "https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.docx"}, "pdf_output": {"output_document": {"filename": "my-template-OR-001.pdf", "s3ref": {"bucket": "document-api-prod", "key": "uploads/my-template.pdf"}}, "preview_url": "https://document-api-prod.s3.eu-central-1.amazonaws.com/preview/my-template-OR-001.pdf"}, "template_settings": {"custom_margins": {"bottom": 2.54, "top": 2.54}, "display_margin_guidelines": true, "enable_data_table_margin_autofix": false, "enabled_template_settings_persistence": false, "file_entity_id": "1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p", "misconfigured_margins": false, "suggested_margins": {"bottom": 2.54, "top": 2.54}, "template_with_datatable": false}}
getJourney:
speakeasy-default-get-journey:
parameters:
Expand Down
57 changes: 45 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" /></a>
</div>

<!-- Start SDK Installation [installation] -->
## SDK Installation
<!-- Start Installation [installation] -->
## Installation

To install this provider, copy and paste this code into your Terraform configuration. Then, run `terraform init`.

Expand All @@ -18,7 +18,7 @@ terraform {
required_providers {
epilot-journey = {
source = "epilot-dev/epilot-journey"
version = "0.5.1"
version = "0.5.2"
}
}
}
Expand All @@ -27,19 +27,17 @@ provider "epilot-journey" {
# Configuration options
}
```
<!-- End SDK Installation [installation] -->
<!-- End Installation [installation] -->

<!-- Start SDK Example Usage [usage] -->
## SDK Example Usage
<!-- Start Testing the provider locally [usage] -->
## Testing the provider locally

### Testing the provider locally
#### Local Provider

Should you want to validate a change locally, the `--debug` flag allows you to execute the provider against a terraform instance locally.

This also allows for debuggers (e.g. delve) to be attached to the provider.

### Example

```sh
go run main.go --debug
# Copy the TF_REATTACH_PROVIDERS env var
Expand All @@ -48,7 +46,30 @@ cd examples/your-example
TF_REATTACH_PROVIDERS=... terraform init
TF_REATTACH_PROVIDERS=... terraform apply
```
<!-- End SDK Example Usage [usage] -->

#### Compiled Provider

Terraform allows you to use local provider builds by setting a `dev_overrides` block in a configuration file called `.terraformrc`. This block overrides all other configured installation methods.

1. Execute `go build` to construct a binary called `terraform-provider-epilot-journey`
2. Ensure that the `.terraformrc` file is configured with a `dev_overrides` section such that your local copy of terraform can see the provider binary

Terraform searches for the `.terraformrc` file in your home directory and applies any configuration settings you set.

```
provider_installation {
dev_overrides {
"registry.terraform.io/epilot-dev/epilot-journey" = "<PATH>"
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
```
<!-- End Testing the provider locally [usage] -->

<!-- Start Summary [summary] -->
## Summary
Expand All @@ -59,10 +80,22 @@ Journey API: API to configure journeys
<!-- Start Table of Contents [toc] -->
## Table of Contents

* [SDK Installation](#sdk-installation)
* [SDK Example Usage](#sdk-example-usage)
* [Installation](#installation)
* [Available Resources and Data Sources](#available-resources-and-data-sources)
* [Testing the provider locally](#testing-the-provider-locally)
<!-- End Table of Contents [toc] -->

<!-- Start Available Resources and Data Sources [operations] -->
## Available Resources and Data Sources

### Resources

* [epilot-journey_journey](docs/resources/journey.md)
### Data Sources

* [epilot-journey_journey](docs/data-sources/journey.md)
<!-- End Available Resources and Data Sources [operations] -->

<!-- Placeholder for Future Speakeasy SDK Sections -->


Expand Down
12 changes: 1 addition & 11 deletions docs/data-sources/journey.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ data "epilot-journey_journey" "my_journey" {
- `context_schema` (Attributes List) (see [below for nested schema](#nestedatt--context_schema))
- `design` (Attributes) (see [below for nested schema](#nestedatt--design))
- `journey_id` (String)
- `logics` (Attributes List) (see [below for nested schema](#nestedatt--logics))
- `logics` (String) Parsed as JSON.
- `manifest` (List of String) Manifest/Blueprint ID used to create/update the entity
- `name` (String)
- `rules` (Attributes List) (see [below for nested schema](#nestedatt--rules))
Expand All @@ -53,16 +53,6 @@ Read-Only:
- `theme` (Map of String)


<a id="nestedatt--logics"></a>
### Nested Schema for `logics`

Read-Only:

- `actions` (List of String)
- `auto_generated_id` (String)
- `conditions` (List of String)


<a id="nestedatt--rules"></a>
### Nested Schema for `rules`

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ terraform {
required_providers {
epilot-journey = {
source = "epilot-dev/epilot-journey"
version = "0.5.1"
version = "0.5.2"
}
}
}
Expand Down
32 changes: 6 additions & 26 deletions docs/resources/journey.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ resource "epilot-journey_journey" "my_journey" {
brand_id = "...my_brand_id..."
context_schema = [
{
is_required = false
is_required = true
param_key = "...my_param_key..."
should_load_entity = false
type = "...my_type..."
Expand All @@ -30,17 +30,7 @@ resource "epilot-journey_journey" "my_journey" {
}
}
journey_id = "...my_journey_id..."
logics = [
{
actions = [
"..."
]
auto_generated_id = "...my_auto_generated_id..."
conditions = [
"..."
]
}
]
logics = "{ \"see\": \"documentation\" }"
manifest = [
"123e4567-e89b-12d3-a456-426614174000"
]
Expand All @@ -65,8 +55,8 @@ resource "epilot-journey_journey" "my_journey" {
}
lang = "en"
mode = "inline"
scroll_to_top = false
top_bar = false
scroll_to_top = true
top_bar = true
width = "...my_width..."
}
entity_id = "...my_entity_id..."
Expand All @@ -80,7 +70,7 @@ resource "epilot-journey_journey" "my_journey" {
runtime_entities = [
"ORDER"
]
safe_mode_automation = false
safe_mode_automation = true
targeted_customer = "...my_targeted_customer..."
template_id = "...my_template_id..."
}
Expand All @@ -102,7 +92,7 @@ resource "epilot-journey_journey" "my_journey" {
- `context_schema` (Attributes List) (see [below for nested schema](#nestedatt--context_schema))
- `design` (Attributes) (see [below for nested schema](#nestedatt--design))
- `journey_id` (String)
- `logics` (Attributes List) (see [below for nested schema](#nestedatt--logics))
- `logics` (String) Parsed as JSON.
- `manifest` (List of String) Manifest/Blueprint ID used to create/update the entity
- `rules` (Attributes List) (see [below for nested schema](#nestedatt--rules))
- `settings` (Attributes) (see [below for nested schema](#nestedatt--settings))
Expand All @@ -127,16 +117,6 @@ Optional:
- `theme` (Map of String)


<a id="nestedatt--logics"></a>
### Nested Schema for `logics`

Optional:

- `actions` (List of String) Not Null
- `auto_generated_id` (String)
- `conditions` (List of String) Not Null


<a id="nestedatt--rules"></a>
### Nested Schema for `rules`

Expand Down
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
epilot-journey = {
source = "epilot-dev/epilot-journey"
version = "0.5.1"
version = "0.5.2"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/resources/epilot-journey_journey/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import epilot-journey_journey.my_epilot-journey_journey ""
63 changes: 63 additions & 0 deletions examples/resources/epilot-journey_journey/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
resource "epilot-journey_journey" "my_journey" {
brand_id = "...my_brand_id..."
context_schema = [
{
is_required = true
param_key = "...my_param_key..."
should_load_entity = false
type = "...my_type..."
}
]
design = {
logo_url = "...my_logo_url..."
theme = {
"see" : jsonencode("documentation"),
}
}
journey_id = "...my_journey_id..."
logics = "{ \"see\": \"documentation\" }"
manifest = [
"123e4567-e89b-12d3-a456-426614174000"
]
name = "...my_name..."
rules = [
{
source = "...my_source..."
source_type = "step"
target = "...my_target..."
type = "inject"
}
]
settings = {
address_suggestions_file_id = "...my_address_suggestions_file_id..."
address_suggestions_file_url = "...my_address_suggestions_file_url..."
description = "...my_description..."
design_id = "...my_design_id..."
embed_options = {
button = {
align = "center"
text = "...my_text..."
}
lang = "en"
mode = "inline"
scroll_to_top = true
top_bar = true
width = "...my_width..."
}
entity_id = "...my_entity_id..."
entity_tags = [
"..."
]
file_purposes = [
"..."
]
mappings_automation_id = "...my_mappings_automation_id..."
runtime_entities = [
"ORDER"
]
safe_mode_automation = true
targeted_customer = "...my_targeted_customer..."
template_id = "...my_template_id..."
}
steps = "{ \"see\": \"documentation\" }"
}
2 changes: 1 addition & 1 deletion gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ generation:
sdkFlattening: true
telemetryEnabled: false
terraform:
version: 0.5.1
version: 0.5.2
additionalDataSources: []
additionalDependencies: {}
additionalResources: []
Expand Down
22 changes: 4 additions & 18 deletions internal/provider/journey_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type JourneyDataSourceModel struct {
ContextSchema []tfTypes.JourneyCreationRequestV2ContextSchema `tfsdk:"context_schema"`
Design *tfTypes.JourneyCreationRequestV2Design `tfsdk:"design"`
JourneyID types.String `tfsdk:"journey_id"`
Logics []tfTypes.JourneyCreationRequestV2Logics `tfsdk:"logics"`
Logics types.String `tfsdk:"logics"`
Manifest []types.String `tfsdk:"manifest"`
Name types.String `tfsdk:"name"`
Rules []tfTypes.JourneyCreationRequestV2Rules `tfsdk:"rules"`
Expand Down Expand Up @@ -89,23 +89,9 @@ func (r *JourneyDataSource) Schema(ctx context.Context, req datasource.SchemaReq
"journey_id": schema.StringAttribute{
Computed: true,
},
"logics": schema.ListNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"actions": schema.ListAttribute{
Computed: true,
ElementType: types.StringType,
},
"auto_generated_id": schema.StringAttribute{
Computed: true,
},
"conditions": schema.ListAttribute{
Computed: true,
ElementType: types.StringType,
},
},
},
"logics": schema.StringAttribute{
Computed: true,
Description: `Parsed as JSON.`,
},
"manifest": schema.ListAttribute{
Computed: true,
Expand Down
Loading

0 comments on commit 31e3b8c

Please sign in to comment.