Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgajard committed Jan 10, 2025
1 parent 88f58b4 commit b3e4124
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
4 changes: 3 additions & 1 deletion pagerdutyplugin/resource_pagerduty_incident_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ func (r *resourceIncidentType) Create(ctx context.Context, req resource.CreateRe
Name: model.Name.ValueString(),
DisplayName: model.DisplayName.ValueString(),
ParentType: model.ParentType.ValueString(),
Enabled: model.Enabled.ValueBoolPointer(),
Description: model.Description.ValueStringPointer(),
}
if !model.Enabled.IsNull() && !model.Enabled.IsUnknown() {
plan.Enabled = model.Enabled.ValueBoolPointer()
}
log.Printf("[INFO] Creating PagerDuty incident type %s", plan.Name)

if list, err := r.client.ListIncidentTypes(ctx, pagerduty.ListIncidentTypesOptions{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (r *resourceIncidentTypeCustomField) Schema(_ context.Context, _ resource.S
"incident_type": schema.StringAttribute{
Required: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
Validators: []validator.String{stringvalidator.LengthAtLeast(1)},
},
"display_name": schema.StringAttribute{
Required: true,
Expand Down
13 changes: 9 additions & 4 deletions website/docs/r/incident_type.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ description: |-
# pagerduty\_incident\_type

An [incident\_type](https://developer.pagerduty.com/api-reference/1981087c1914c-create-an-incident-type)
are a feature which will allow customers to categorize incidents, such as a
security incident, a major incident, or a fraud incident.
is a feature which allows customers to categorize incidents, such as a security
incident, a major incident, or a fraud incident.

<div role="alert" class="alert alert-warning">
<div class="alert-title"><i class="fa fa-warning"></i>Resource limitation</div>
<p>Incident Types cannot be deleted, only disabled</p>
</div>


## Example Usage
Expand All @@ -33,7 +38,7 @@ resource "pagerduty_incident_type" "example" {
The following arguments are supported:

* `name` - (Required) The name of the Incident Type. Usage of the suffix `_default` is prohibited. This cannot be changed once the incident type has been created.
* `display_name` - (Required) The display name of the Incident Type. Usage of the prefix PD, PagerDuty, Default is prohibited.
* `display_name` - (Required) The display name of the Incident Type. Usage of the prefixes PD, PagerDuty, or the suffixes Default, or (Default) is prohibited.
* `parent_type` - (Required) The parent type of the Incident Type. Either name or id of the parent type can be used.
* `description` - A succinct description of the Incident Type.
* `enabled` - State of this Incident Type object. Defaults to true if not provided.
Expand All @@ -48,5 +53,5 @@ The following arguments are supported:
Services can be imported using the `id`, e.g.

```
$ terraform import pagerduty_service.main P12345
$ terraform import pagerduty_incident_type.main P12345
```
35 changes: 22 additions & 13 deletions website/docs/r/incident_type_custom_field.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,41 @@ An [incident type custom fields](https://developer.pagerduty.com/api-reference/4
are a feature which will allow customers to extend Incidents with their own
custom data, to provide additional context and support features such as
customized filtering, search and analytics. Custom Fields can be applied to
different incident types.
different incident types. Child types will inherit custom fields from their
parent types.


## Example Usage

```hcl
resource "pagerduty_incident_custom_field" "alarm_time" {
resource "pagerduty_incident_type_custom_field" "alarm_time" {
name = "alarm_time_minutes"
display_name = "Alarm Time"
data_type = "integer"
field_type = "single_value"
default_value = jsonencode(5)
incident_type = "incident_default"
}
data "pagerduty_incident_type" "foo" {
display_name = "Foo"
}
resource "pagerduty_incident_custom_field" "level" {
name = "level"
display_name = "Level"
data_type = "string"
field_type = "single_value_fixed"
resource "pagerduty_incident_type_custom_field" "level" {
name = "level"
incident_type = data.pagerduty_incident_type.foo.id
display_name = "Level"
data_type = "string"
field_type = "single_value_fixed"
field_options = ["Trace", "Debug", "Info", "Warn", "Error", "Fatal"]
}
resource "pagerduty_incident_custom_field" "cs_impact" {
name = "impact"
display_name = "Customer Impact"
data_type = "string"
field_type = "multi_value"
resource "pagerduty_incident_type_custom_field" "cs_impact" {
name = "impact"
incident_type = data.pagerduty_incident_type.foo.id
display_name = "Customer Impact"
data_type = "string"
field_type = "multi_value"
}
```

Expand All @@ -52,7 +61,7 @@ The following arguments are supported:
* `field_type` - (Required) [Updating causes resource replacement] The field type of the field. Must be one of `single_value`, `single_value_fixed`, `multi_value`, or `multi_value_fixed`.
* `description` - The description of the custom field.
* `default_value` - The default value to set when new incidents are created. Always specified as a string.
* `enabled` - Whether the custom field is enabled.
* `enabled` - Whether the custom field is enabled. Defaults to true if not provided.
* `field_options` - The options for the custom field. Can only be applied to fields with a type of `single_value_fixed` or `multi_value_fixed`.

## Attributes Reference
Expand Down

0 comments on commit b3e4124

Please sign in to comment.