Skip to content

Commit

Permalink
Merge pull request #33 from kenzo0107/support_template_and_template_v…
Browse files Browse the repository at this point in the history
…ersion

Support template and template version
  • Loading branch information
kenzo0107 authored Jan 29, 2024
2 parents d21db71 + e502b0e commit 3172ea5
Show file tree
Hide file tree
Showing 31 changed files with 1,478 additions and 32 deletions.
8 changes: 4 additions & 4 deletions docs/data-sources/subuser.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
page_title: "sendgrid_subuser Data Source - terraform-provider-sendgrid"
subcategory: ""
description: |-
Your application, mail client, or website can all use API (Application Programming Interface) keys to authenticate access to SendGrid services. You can revoke an API key at any time without having to change your username and password, and an API key can be scoped to perform a limited number of actions.
Provides a API Key resource.
Provides a subuser resource.
Subusers help you segment your email sending and API activity. You assign permissions and credit limits when you create the subuser. We recommend creating subusers for each of the different types of emails you send - one subuser for transactional emails, and another for marketing emails. Breaking your sending up this way allows you to get separate statistics for each type of email you send.
For more detailed information, please see the SendGrid documentation https://docs.sendgrid.com/ui/account-and-settings/api-keys.
---

# sendgrid_subuser (Data Source)

Your application, mail client, or website can all use API (Application Programming Interface) keys to authenticate access to SendGrid services. You can revoke an API key at any time without having to change your username and password, and an API key can be scoped to perform a limited number of actions.
Provides a subuser resource.

Provides a API Key resource.
Subusers help you segment your email sending and API activity. You assign permissions and credit limits when you create the subuser. We recommend creating subusers for each of the different types of emails you send - one subuser for transactional emails, and another for marketing emails. Breaking your sending up this way allows you to get separate statistics for each type of email you send.

For more detailed information, please see the [SendGrid documentation](https://docs.sendgrid.com/ui/account-and-settings/api-keys).

Expand Down
44 changes: 44 additions & 0 deletions docs/data-sources/template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sendgrid_template Data Source - terraform-provider-sendgrid"
subcategory: ""
description: |-
Provides template resource.
An HTML template that can establish a consistent design for transactional emails https://sendgrid.com/use-cases/transactional-email/.
Each parent account, as well as each Subuser, can create up to 300 different transactional templates. Templates are specific to the parent account or Subuser, meaning templates created on a parent account will not be accessible from the parent's Subuser accounts.
Transactional templates are templates created specifically for transactional email and are not to be confused with Marketing Campaigns designs https://sendgrid.com/docs/ui/sending-email/working-with-marketing-campaigns-email-designs/. For more information about transactional templates, please see our Dynamic Transactional Templates documentation https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/.
---

# sendgrid_template (Data Source)

Provides template resource.

An HTML template that can establish a consistent design for [transactional emails](https://sendgrid.com/use-cases/transactional-email/).

Each parent account, as well as each Subuser, can create up to 300 different transactional templates. Templates are specific to the parent account or Subuser, meaning templates created on a parent account will not be accessible from the parent's Subuser accounts.

Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns designs](https://sendgrid.com/docs/ui/sending-email/working-with-marketing-campaigns-email-designs/). For more information about transactional templates, please see our [Dynamic Transactional Templates documentation](https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/).

## Example Usage

```terraform
data "sendgrid_template" "example" {
id = "d-1234567890abcdefghijklmnopqrstuv"
}
output "name" {
value = data.sendgrid_template.example.name
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) The ID of the transactional template.

### Read-Only

- `generation` (String) Defines the generation of the template.
- `name` (String) The name for the transactional template.
50 changes: 50 additions & 0 deletions docs/data-sources/template_version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sendgrid_template_version Data Source - terraform-provider-sendgrid"
subcategory: ""
description: |-
Provides a template version resource.
Represents the code for a particular transactional template. Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
For more information about transactional templates, please see our Transactional Templates documentation. You can also manage your Transactional Templates in the Dynamic Templates section of the Twilio SendGrid App.
---

# sendgrid_template_version (Data Source)

Provides a template version resource.

Represents the code for a particular transactional template. Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.

For more information about transactional templates, please see our Transactional Templates documentation. You can also manage your Transactional Templates in the Dynamic Templates section of the Twilio SendGrid App.

## Example Usage

```terraform
data "sendgrid_template_version" "example" {
template_id = "d-1234567890abcdefghijklmnopqrstuv"
id = "abcde123-fg45-6789-012e-3456789abcde"
}
output "name" {
value = data.sendgrid_template_version.example.name
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) The ID of the transactional template version.
- `template_id` (String) The ID of the transactional template.

### Read-Only

- `active` (Number) Set the version as the active version associated with the template (0 is inactive, 1 is active). Only one version of a template can be active. The first version created for a template will automatically be set to Active. Allowed Values: 0, 1
- `editor` (String) The editor used in the UI.
- `generate_plain_content` (Boolean) If true, plain_content is always generated from html_content. If false, plain_content is not altered.
- `html_content` (String) The HTML content of the version. Maximum of 1048576 bytes allowed.
- `name` (String) The name for the transactional template.
- `plain_content` (String) Text/plain content of the transactional template version. Maximum of 1048576 bytes allowed.
- `subject` (String) Subject of the new transactional template version. maxLength: 255
- `test_data` (String) For dynamic templates only, the mock json data that will be used for template preview and test sends.
- `thumbnail_url` (String) A Thumbnail preview of the template's html content.
32 changes: 20 additions & 12 deletions docs/data-sources/unsubscribe_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,40 @@
page_title: "sendgrid_unsubscribe_group Data Source - terraform-provider-sendgrid"
subcategory: ""
description: |-
Provides a subuser resource.
Suppression groups, or unsubscribe groups, are specific types or categories of emails from which you would like your recipients to be able to unsubscribe. For example: Daily Newsletters, Invoices, and System Alerts are all potential suppression groups.
Visit the main documentation to [learn more about suppression/unsubscribe groups](https://sendgrid.com/docs/ui/sending-email/unsubscribe-groups/).
Provides suppressions unsubscribe group resource.
Suppression groups, or unsubscribe groups, are specific types or categories of emails from which you would like your recipients to be able to unsubscribe. For example: Daily Newsletters, Invoices, and System Alerts are all potential suppression groups.
Visit the main documentation to learn more about suppression/unsubscribe groups https://sendgrid.com/docs/ui/sending-email/unsubscribe-groups/.
---

# sendgrid_unsubscribe_group (Data Source)

Provides a subuser resource.
Provides suppressions unsubscribe group resource.

Suppression groups, or unsubscribe groups, are specific types or categories of emails from which you would like your recipients to be able to unsubscribe. For example: Daily Newsletters, Invoices, and System Alerts are all potential suppression groups.
Suppression groups, or unsubscribe groups, are specific types or categories of emails from which you would like your recipients to be able to unsubscribe. For example: Daily Newsletters, Invoices, and System Alerts are all potential suppression groups.

Visit the main documentation to [learn more about suppression/unsubscribe groups](https://sendgrid.com/docs/ui/sending-email/unsubscribe-groups/).
Visit the main documentation to [learn more about suppression/unsubscribe groups](https://sendgrid.com/docs/ui/sending-email/unsubscribe-groups/).

## Example Usage

```terraform
data "sendgrid_unsubscribe_group" "example" {
id = "13253"
}
output "name" {
value = data.sendgrid_unsubscribe_group.example.name
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) The ID of the verified sender.
- `id` (String) The ID of the unsubscribe group.

### Read-Only

- `description` (String) This will display to the user as the email address that sent this email. We will send the verification email to the address you enter in this field. If you have not received your verification email after some time, please refer back to the Sender settings and confirm that the "From" email is a valid address.
- `is_default` (Boolean) This is a user-friendly name that is displayed to your recipient when they receive their email.
- `name` (String) A label for your sender identity to help you identify it more quickly. This label is not visible to your recipients.
- `description` (String) A brief description of your suppression group.
- `is_default` (Boolean) Indicates if you would like this to be your default suppression group.
- `name` (String) The name of your suppression group.
52 changes: 52 additions & 0 deletions docs/resources/template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sendgrid_template Resource - terraform-provider-sendgrid"
subcategory: ""
description: |-
Provides template resource.
An HTML template that can establish a consistent design for transactional emails https://sendgrid.com/use-cases/transactional-email/.
Each parent account, as well as each Subuser, can create up to 300 different transactional templates. Templates are specific to the parent account or Subuser, meaning templates created on a parent account will not be accessible from the parent's Subuser accounts.
Transactional templates are templates created specifically for transactional email and are not to be confused with Marketing Campaigns designs https://sendgrid.com/docs/ui/sending-email/working-with-marketing-campaigns-email-designs/. For more information about transactional templates, please see our Dynamic Transactional Templates documentation https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/.
---

# sendgrid_template (Resource)

Provides template resource.

An HTML template that can establish a consistent design for [transactional emails](https://sendgrid.com/use-cases/transactional-email/).

Each parent account, as well as each Subuser, can create up to 300 different transactional templates. Templates are specific to the parent account or Subuser, meaning templates created on a parent account will not be accessible from the parent's Subuser accounts.

Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns designs](https://sendgrid.com/docs/ui/sending-email/working-with-marketing-campaigns-email-designs/). For more information about transactional templates, please see our [Dynamic Transactional Templates documentation](https://sendgrid.com/docs/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates/).

## Example Usage

```terraform
resource "sendgrid_template" "example" {
name = "dummy"
generation = "dynamic"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name for the transactional template. maxLength: 100

### Optional

- `generation` (String) Defines the generation of the template. Allowed Values: `legacy`, `dynamic`

### Read-Only

- `id` (String) The ID of the transactional template.

## Import

Import is supported using the following syntax:

```shell
% terraform import sendgrid_template.example <template id>
```
67 changes: 67 additions & 0 deletions docs/resources/template_version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sendgrid_template_version Resource - terraform-provider-sendgrid"
subcategory: ""
description: |-
Provides a template version resource.
Represents the code for a particular transactional template. Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.
For more information about transactional templates, please see our Transactional Templates documentation. You can also manage your Transactional Templates in the Dynamic Templates section of the Twilio SendGrid App.
---

# sendgrid_template_version (Resource)

Provides a template version resource.

Represents the code for a particular transactional template. Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates.

For more information about transactional templates, please see our Transactional Templates documentation. You can also manage your Transactional Templates in the Dynamic Templates section of the Twilio SendGrid App.

## Example Usage

```terraform
resource "sendgrid_template" "example" {
name = "dummy"
generation = "dynamic"
}
resource "sendgrid_template_version" "example" {
template_id = sendgrid_template.example.id
name = "dummy"
active = 1
test_data = jsonencode({
"name" : "dummy"
})
html_content = "<%body%>"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name for the transactional template.
- `template_id` (String) The ID of the transactional template.

### Optional

- `active` (Number) Set the version as the active version associated with the template (0 is inactive, 1 is active). Only one version of a template can be active. The first version created for a template will automatically be set to Active. Allowed Values: 0, 1
- `editor` (String) The editor used in the UI.
- `generate_plain_content` (Boolean) If true, plain_content is always generated from html_content. If false, plain_content is not altered.
- `html_content` (String) The HTML content of the version. Maximum of 1048576 bytes allowed.
- `plain_content` (String) Text/plain content of the transactional template version. Maximum of 1048576 bytes allowed.
- `subject` (String) Subject of the new transactional template version. maxLength: 255
- `test_data` (String) For dynamic templates only, the mock json data that will be used for template preview and test sends.

### Read-Only

- `id` (String) The ID of the transactional template version.
- `thumbnail_url` (String) A Thumbnail preview of the template's html content.

## Import

Import is supported using the following syntax:

```shell
% terraform import sendgrid_template_version.example <template id>/<template version id>
```
14 changes: 11 additions & 3 deletions docs/resources/unsubscribe_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
page_title: "sendgrid_unsubscribe_group Resource - terraform-provider-sendgrid"
subcategory: ""
description: |-
Provides a subuser resource.
Provides suppressions unsubscribe group resource.
Suppression groups, or unsubscribe groups, are specific types or categories of emails from which you would like your recipients to be able to unsubscribe. For example: Daily Newsletters, Invoices, and System Alerts are all potential suppression groups.
Visit the main documentation to learn more about suppression/unsubscribe groups https://sendgrid.com/docs/ui/sending-email/unsubscribe-groups/.
---

# sendgrid_unsubscribe_group (Resource)

Provides a subuser resource.
Provides suppressions unsubscribe group resource.

Suppression groups, or unsubscribe groups, are specific types or categories of emails from which you would like your recipients to be able to unsubscribe. For example: Daily Newsletters, Invoices, and System Alerts are all potential suppression groups.

Expand Down Expand Up @@ -40,4 +40,12 @@ resource "sendgrid_unsubscribe_group" "example" {

### Read-Only

- `id` (String) The user ID of the unsubscribe group.
- `id` (String) The ID of the unsubscribe group.

## Import

Import is supported using the following syntax:

```shell
% terraform import sendgrid_unsubscribe_group.example <unsubscribe group id>
```
8 changes: 8 additions & 0 deletions examples/data-sources/sendgrid_template/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

data "sendgrid_template" "example" {
id = "d-1234567890abcdefghijklmnopqrstuv"
}

output "name" {
value = data.sendgrid_template.example.name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

data "sendgrid_template_version" "example" {
template_id = "d-1234567890abcdefghijklmnopqrstuv"
id = "abcde123-fg45-6789-012e-3456789abcde"
}

output "name" {
value = data.sendgrid_template_version.example.name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "sendgrid_unsubscribe_group" "example" {
id = "13253"
}

output "name" {
value = data.sendgrid_unsubscribe_group.example.name
}
1 change: 1 addition & 0 deletions examples/resources/sendgrid_template/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
% terraform import sendgrid_template.example <template id>
4 changes: 4 additions & 0 deletions examples/resources/sendgrid_template/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "sendgrid_template" "example" {
name = "dummy"
generation = "dynamic"
}
1 change: 1 addition & 0 deletions examples/resources/sendgrid_template_version/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
% terraform import sendgrid_template_version.example <template id>/<template version id>
14 changes: 14 additions & 0 deletions examples/resources/sendgrid_template_version/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "sendgrid_template" "example" {
name = "dummy"
generation = "dynamic"
}

resource "sendgrid_template_version" "example" {
template_id = sendgrid_template.example.id
name = "dummy"
active = 1
test_data = jsonencode({
"name" : "dummy"
})
html_content = "<%body%>"
}
1 change: 1 addition & 0 deletions examples/resources/sendgrid_unsubscribe_group/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
% terraform import sendgrid_unsubscribe_group.example <unsubscribe group id>
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/hashicorp/terraform-plugin-framework v1.3.5
github.com/hashicorp/terraform-plugin-go v0.18.0
github.com/hashicorp/terraform-plugin-testing v1.5.1
github.com/kenzo0107/sendgrid v0.0.13
github.com/kenzo0107/sendgrid v0.0.14
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ github.com/kenzo0107/sendgrid v0.0.12 h1:MFiauMa3VkOofA1grZ8iqVdj9X/crE+B3Z42U9+
github.com/kenzo0107/sendgrid v0.0.12/go.mod h1:QjjiRx0jvq2ldgR7U9pnoW+F3wf/E9pVUed04pReuPU=
github.com/kenzo0107/sendgrid v0.0.13 h1:tuEXgYvKMcqLImrXeVgfpxY90eBmZUNZBJOM1I7r6hQ=
github.com/kenzo0107/sendgrid v0.0.13/go.mod h1:QjjiRx0jvq2ldgR7U9pnoW+F3wf/E9pVUed04pReuPU=
github.com/kenzo0107/sendgrid v0.0.14 h1:PRciITixk/lFV5u0115GNnPR2jWcDrWzTF7lGjbrrz4=
github.com/kenzo0107/sendgrid v0.0.14/go.mod h1:QjjiRx0jvq2ldgR7U9pnoW+F3wf/E9pVUed04pReuPU=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
Expand Down
Loading

0 comments on commit 3172ea5

Please sign in to comment.