From 0e8ecd45f3ee22db03a1a60fddaaf48a7a1215d9 Mon Sep 17 00:00:00 2001 From: dheeruk12 <96110782+dheeruk12@users.noreply.github.com> Date: Thu, 26 Oct 2023 14:07:09 +0530 Subject: [PATCH] add docs for postincident tasks and tasktemplates --- docs/resources/zenduty_post_incident_tasks.md | 67 +++++++++++++++ docs/resources/zenduty_task_template_tasks.md | 81 +++++++++++++++++++ docs/resources/zenduty_task_templates.md | 62 ++++++++++++++ zenduty/resource_post_incident_tasks.go | 18 +++-- zenduty/resource_task_template_tasks.go | 2 + 5 files changed, 225 insertions(+), 5 deletions(-) create mode 100644 docs/resources/zenduty_post_incident_tasks.md create mode 100644 docs/resources/zenduty_task_template_tasks.md create mode 100644 docs/resources/zenduty_task_templates.md diff --git a/docs/resources/zenduty_post_incident_tasks.md b/docs/resources/zenduty_post_incident_tasks.md new file mode 100644 index 0000000..80af4e4 --- /dev/null +++ b/docs/resources/zenduty_post_incident_tasks.md @@ -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 + + + + + diff --git a/docs/resources/zenduty_task_template_tasks.md b/docs/resources/zenduty_task_template_tasks.md new file mode 100644 index 0000000..46abe9f --- /dev/null +++ b/docs/resources/zenduty_task_template_tasks.md @@ -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 + + + + + diff --git a/docs/resources/zenduty_task_templates.md b/docs/resources/zenduty_task_templates.md new file mode 100644 index 0000000..67a06b6 --- /dev/null +++ b/docs/resources/zenduty_task_templates.md @@ -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 + + + + + diff --git a/zenduty/resource_post_incident_tasks.go b/zenduty/resource_post_incident_tasks.go index 1859988..a720116 100644 --- a/zenduty/resource_post_incident_tasks.go +++ b/zenduty/resource_post_incident_tasks.go @@ -44,7 +44,7 @@ func resourcePostIncidentTasks() *schema.Resource { }, "assigned_to": { Type: schema.TypeString, - Required: true, + Optional: true, }, "status": { Type: schema.TypeInt, @@ -54,7 +54,7 @@ func resourcePostIncidentTasks() *schema.Resource { }, "due_in_time": { Type: schema.TypeString, - Required: true, + Optional: true, }, "creation_date": { Type: schema.TypeString, @@ -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) } @@ -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 diff --git a/zenduty/resource_task_template_tasks.go b/zenduty/resource_task_template_tasks.go index f4709a0..73e357c 100644 --- a/zenduty/resource_task_template_tasks.go +++ b/zenduty/resource_task_template_tasks.go @@ -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