Skip to content

Commit

Permalink
add docs for postincident tasks and tasktemplates
Browse files Browse the repository at this point in the history
  • Loading branch information
dheeruk12 committed Oct 26, 2023
1 parent 87e68ba commit 0e8ecd4
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 5 deletions.
67 changes: 67 additions & 0 deletions docs/resources/zenduty_post_incident_tasks.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: "Zenduty: PostIncidentTasks"
subcategory: ""
description: |-
Provides a Zenduty PostIncidentTasks Resource. This allows PostIncidentTasks to be created, updated, and deleted.
---

# Resource : zenduty_post_incident_tasks
Provides a Zenduty PostIncidentTasks Resource. This allows PostIncidentTasks to be created, updated, and deleted.
## Example Usage
```hcl
resource "zenduty_teams" "exampleteam" {
name = "exmaple team"
}
```


```hcl
resource "zenduty_post_incident_tasks" "demotask" {
title = "demo task template"
description = "this is a description of demo task"
team_id = zenduty_teams.exampleteam.id
due_in_time = "YYYY-MM-DD HH:MM"
status = 0
}
```


## Argument Reference

* `team_id` - (Required) The unique_id of team.
* `title` - (Required) The title of the task.
* `description` - (Required) The description of the task.
* `status` - (Optional) the status of the task choices are `0` is To-Do,`1` is In-Progress, `2`- Done
* `due_in_time` - (Optional) The due time of the task in format YYYY-MM-DD HH:MM.
* `assigned_to` - (Optional) username of the user to assign the task
## Attributes Reference

The following attributes are exported:

* `id` - The ID of the Zenduty PostIncidentTasks.

## Import

Team PostIncidentTask can be imported using the `team_id`(ie. unique_id of the team) and `task_id`(ie. unique_id of the task template)

```hcl
resource "zenduty_post_incident_tasks" "demotask" {
}
```

`$ terraform import zenduty_post_incident_tasks.demotask team_id/task_id`

`$ terraform state show zenduty_post_incident_tasks.demotask`

`* copy the output data and paste inside zenduty_post_incident_tasks.demotask resource block and remove the id attribute`

`$ terraform plan` to verify the import





81 changes: 81 additions & 0 deletions docs/resources/zenduty_task_template_tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "Zenduty: TaskTemplateTasks"
subcategory: ""
description: |-
Provides a Zenduty TaskTemplateTasks Resource. This allows TaskTemplateTasks to be created, updated, and deleted.
---

# Resource : zenduty_task_template_tasks
Provides a Zenduty TaskTemplateTasks Resource. This allows TaskTemplateTasks to be created, updated, and deleted.
## Example Usage
```hcl
resource "zenduty_teams" "exampleteam" {
name = "exmaple team"
}
resource "zenduty_task_template_tasks" "demotemplate" {
name = "example template"
summary = "this is an example template"
team_id = zenduty_teams.exampleteam.id
}
resource "zenduty_roles" "example_role" {
team = zenduty_teams.exampleteam.id
title = "Example Role"
description = "Role Description"
}
```


```hcl
resource "zenduty_task_template_tasks" "demotask" {
team_id = "af0e6c8a-c895-434c-b667-2f44833e15b6"
task_template_id = zenduty_task_template_tasks.demotemplate.id
title = "demo task"
description = "this is a description of demo task"
role = zenduty_roles.example_role.id
}
```


## Argument Reference

* `team_id` - (Required) The unique_id of team.
* `task_template_id` - (Required) The unique_id of tasktemplate to create the tasktemplatetasks in.
* `title` - (Required) The title of the task.
* `description` - (Required) The description of the task.
* `role` - (Optional) The unique_id of incident role attached to the task
* `due_in` - (Optional) Time in minutes to complete the task `-1` => no due time

## Attributes Reference

The following attributes are exported:

* `id` - The ID of the Zenduty TaskTemplateTask.

## Import

Team TaskTemplate can be imported using the `team_id`(ie. unique_id of the team) and `task_template_id`(ie. unique_id of the task template), and `task_template_task_id` (ie. unique_id of the task template task id) .

```hcl
resource "zenduty_task_template_tasks" "demotemplatetask" {
}
```

`$ terraform import zenduty_task_template_tasks.demotemplatetask team_id/task_template_id/task_template_task_id`

`$ terraform state show zenduty_task_template_tasks.demotemplatetask`

`* copy the output data and paste inside zenduty_task_template_tasks.demotemplatetask resource block and remove the id attribute`

`$ terraform plan` to verify the import





62 changes: 62 additions & 0 deletions docs/resources/zenduty_task_templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "Zenduty: TaskTemplates"
subcategory: ""
description: |-
Provides a Zenduty TaskTemplates Resource. This allows TaskTemplates to be created, updated, and deleted.
---

# Resource : zenduty_task_templates
Provides a Zenduty TaskTemplates Resource. This allows TaskTemplates to be created, updated, and deleted.
## Example Usage
```hcl
resource "zenduty_teams" "exampleteam" {
name = "exmaple team"
}
```

```hcl
resource "zenduty_task_templates" "demotemplate" {
name = "example template"
summary = "this is an example template"
team_id = zenduty_teams.exampleteam.id
}
```


## Argument Reference

* `team_id` - (Required) The unique_id of team to create the tasktemplate in.
* `name` - (Required) The name of the tasktemplate.
* `summary` - (Required) The summary of the tasktemplate.

## Attributes Reference

The following attributes are exported:

* `id` - The ID of the Zenduty TaskTemplate.

## Import

Team TaskTemplate can be imported using the `team_id`(ie. unique_id of the team) and `task_template_id`(ie. unique_id of the task template), e.g.

```hcl
resource "zenduty_task_templates" "demotemplate" {
}
```

`$ terraform import zenduty_task_templates.demotemplate team_id/task_template_id`

`$ terraform state show zenduty_task_templates.demotemplate`

`* copy the output data and paste inside zenduty_task_templates.demotemplate resource block and remove the id attribute`

`$ terraform plan` to verify the import





18 changes: 13 additions & 5 deletions zenduty/resource_post_incident_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func resourcePostIncidentTasks() *schema.Resource {
},
"assigned_to": {
Type: schema.TypeString,
Required: true,
Optional: true,
},
"status": {
Type: schema.TypeInt,
Expand All @@ -54,7 +54,7 @@ func resourcePostIncidentTasks() *schema.Resource {
},
"due_in_time": {
Type: schema.TypeString,
Required: true,
Optional: true,
},
"creation_date": {
Type: schema.TypeString,
Expand Down Expand Up @@ -95,11 +95,16 @@ func CreatePostIncidentTask(Ctx context.Context, d *schema.ResourceData, m inter
if v, ok := d.GetOk("assigned_to"); ok {
newpostincidenttask.AssignedTo = v.(string)
}
if v, ok := d.GetOk("status"); ok {
newpostincidenttask.Status = v.(int)
}
if v, ok := d.GetOk("due_in_time"); ok {
newpostincidenttask.DueInTime = v.(string)
DueInTime := v.(string)
newpostincidenttask.DueInTime = &DueInTime
parsedTime, parsedErr := time.Parse("2006-01-02 15:04", v.(string))
if parsedErr == nil {
newpostincidenttask.DueInTime = parsedTime.In(time.UTC).Format(time.RFC3339)
formattedTime := parsedTime.In(time.UTC).Format(time.RFC3339)
newpostincidenttask.DueInTime = &formattedTime
} else {
return nil, diag.FromErr(parsedErr)
}
Expand Down Expand Up @@ -183,12 +188,15 @@ func resourceReadPostIncidentTasks(Ctx context.Context, d *schema.ResourceData,
if err != nil {
return diag.FromErr(err)
}

d.Set("title", postincidenttask.Title)
d.Set("description", postincidenttask.Description)
d.Set("assigned_to", postincidenttask.AssignedTo)
d.Set("status", postincidenttask.Status)
d.Set("team_id", teamID)
d.Set("due_in_time", parseDueInTime(postincidenttask.DueInTime))
if postincidenttask.DueInTime != nil {
d.Set("due_in_time", parseDueInTime(*postincidenttask.DueInTime))
}
d.Set("creation_date", postincidenttask.CreationDate)

return diags
Expand Down
2 changes: 2 additions & 0 deletions zenduty/resource_task_template_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func CreateTaskTemplateTask(Ctx context.Context, d *schema.ResourceData, m inter
if v, ok := d.GetOk("task_template_id"); ok {
newTaskTemplateTask.TaskTemplate = v.(string)
}
position := d.Get("position").(int)
newTaskTemplateTask.Positon = position

return newTaskTemplateTask, nil

Expand Down

0 comments on commit 0e8ecd4

Please sign in to comment.