Skip to content

Commit

Permalink
Merge pull request #15 from dheeruk12/main
Browse files Browse the repository at this point in the history
Add support for sla ,postincidenttasks, task_templates
  • Loading branch information
vishwa306 authored Oct 26, 2023
2 parents 530ded0 + 025a808 commit 0f4c941
Show file tree
Hide file tree
Showing 12 changed files with 1,235 additions and 1 deletion.
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





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

# Resource : zenduty_sla
Provides a Zenduty SLAs Resource. This allows SLAs to be created, updated, and deleted.
## Example Usage
```hcl
resource "zenduty_teams" "exampleteam" {
name = "exmaple team"
}
data "zenduty_user" "user1" {
email = "demouser@gmail.com"
}
```

```hcl
resource "zenduty_sla" "example_sla" {
name = "demo sla"
description = "this is a demo sla"
team_id = zenduty_teams.exampleteam.id
acknowledge_time = 5
resolve_time = 10
escalations {
time = 30
type = 1
responders {
user = data.zenduty_user.user1.users[0].username
}
}
escalations {
time = -10
type = 2
responders {
user = data.zenduty_user.user1.users[0].username
}
}
}
```


## Argument Reference

* `team_id` - (Required) The unique_id of team to create the sla in.
* `name` - (Required) The name of the sla.
* `description` - (Required) The description of the sla
* `acknowledge_time` - (Required) time in seconds to trigger SLA if not acknowledged.
* `resolve_time` - (Required) Time in seconds to trigger SLA if not resolved.
* `escalations` - (Required) Reminders when an SLA is breached or about to breach. (see [below for nested schema](#nestedblock--escalation))

```hcl
escalations {
time = 30
type = 1
responders {
user = data.zenduty_user.user1.users[0].username
}
}
```

<a id="nestedblock--escalation"></a>

* `type`: It is an integer field that determines the type of notification behavior. `1` signifies that notifications are sent when the SLA breach is acknowledged, while `2` indicates notifications for resolution SLA breaches.
* `time`: This field specifies the time duration in seconds when notifications should be sent. If time is positive, it means notifications will be sent x seconds after the SLA breach, and if it's negative, notifications will be sent x seconds before the breach.
* `responders` - users who need to be paged when an SLA is breached. (see [below for nested schema](#nestedblock--responders))


<a id="nestedblock--responders"></a>

```hcl
responders {
user = data.zenduty_user.user1.users[0].username
}
```
* `user` - Username of the user who will be notified if sla is breached






## Attributes Reference

The following attributes are exported:

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

## Import

Team SLAs can be imported using the `team_id`(ie. unique_id of the team) and `sla_id`(ie. unique_id of the sla), e.g.

```hcl
resource "zenduty_sla" "sla1" {
}
```

`$ terraform import zenduty_sla.sla1 team_id/sla_id`

`$ terraform state show zenduty_sla.sla1`

`* copy the output data and paste inside zenduty_sla.sla1 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





3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module terraform-provider-zenduty
go 1.17

require (
github.com/Zenduty/zenduty-go-sdk v0.1.7
github.com/Zenduty/zenduty-go-sdk v0.1.8
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
)
Expand All @@ -16,6 +16,7 @@ require (
github.com/fatih/color v1.7.0 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/uuid v1.3.1
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C6
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/Zenduty/zenduty-go-sdk v0.1.7 h1:IojKvlQAKI6/5GnicYCFLtz7+J6vnG+PsHlUB5aZAGk=
github.com/Zenduty/zenduty-go-sdk v0.1.7/go.mod h1:XnK1p2uyFpBUwbW+xecKSww0klZOSKKoywobqGDlFE8=
github.com/Zenduty/zenduty-go-sdk v0.1.8 h1:vREmE/XO+nVR7oZ0JLp2W18QTl8r3a6ymsYY7BwDAIg=
github.com/Zenduty/zenduty-go-sdk v0.1.8/go.mod h1:XnK1p2uyFpBUwbW+xecKSww0klZOSKKoywobqGDlFE8=
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
Expand Down Expand Up @@ -150,6 +152,8 @@ github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
Expand Down
7 changes: 7 additions & 0 deletions zenduty/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"regexp"
"strings"

"github.com/google/uuid"
"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -113,3 +114,9 @@ func ValidateRequired() schema.SchemaValidateDiagFunc {
}

}

func genrateUUID() string {
id := uuid.New()
uuidString := id.String()
return uuidString
}
4 changes: 4 additions & 0 deletions zenduty/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func Provider() *schema.Provider {
"zenduty_assign_account_role": resourceAssignAccountRole(),
"zenduty_globalrouter": resourceGlobalRouter(),
"zenduty_globalrouting_rule": resourceGlobalRoutingRules(),
"zenduty_sla": resourceSLA(),
"zenduty_post_incident_tasks": resourcePostIncidentTasks(),
"zenduty_task_templates": resourceTaskTemplates(),
"zenduty_task_template_tasks": resourceTaskTemplateTaskTasks(),
},

DataSourcesMap: map[string]*schema.Resource{
Expand Down
Loading

0 comments on commit 0f4c941

Please sign in to comment.