From 92bafc6363381f84bca554bfa9b7221e4703694a Mon Sep 17 00:00:00 2001 From: Alex Mingoia Date: Sat, 23 Dec 2023 02:10:10 +0630 Subject: [PATCH] v1.0.0 --- providers/rootly/cause.go | 67 ++++++ providers/rootly/dashboard.go | 67 ++++++ providers/rootly/environment.go | 67 ++++++ providers/rootly/form_field.go | 204 +++++++++++++++++ providers/rootly/functionality.go | 67 ++++++ providers/rootly/incident_role.go | 140 ++++++++++++ providers/rootly/incident_type.go | 67 ++++++ providers/rootly/playbook.go | 140 ++++++++++++ providers/rootly/post_mortem_template.go | 67 ++++++ providers/rootly/retrospective_step.go | 67 ++++++ providers/rootly/rootly_provider.go | 3 + providers/rootly/secret.go | 67 ++++++ providers/rootly/service.go | 67 ++++++ providers/rootly/severity.go | 67 ++++++ providers/rootly/status_page.go | 140 ++++++++++++ providers/rootly/team.go | 67 ++++++ providers/rootly/webhooks_endpoint.go | 67 ++++++ providers/rootly/workflow.go | 268 +++++++++++++++++++++++ providers/rootly/workflow_group.go | 67 ++++++ 19 files changed, 1766 insertions(+) create mode 100644 providers/rootly/cause.go create mode 100644 providers/rootly/dashboard.go create mode 100644 providers/rootly/environment.go create mode 100644 providers/rootly/form_field.go create mode 100644 providers/rootly/functionality.go create mode 100644 providers/rootly/incident_role.go create mode 100644 providers/rootly/incident_type.go create mode 100644 providers/rootly/playbook.go create mode 100644 providers/rootly/post_mortem_template.go create mode 100644 providers/rootly/retrospective_step.go create mode 100644 providers/rootly/secret.go create mode 100644 providers/rootly/service.go create mode 100644 providers/rootly/severity.go create mode 100644 providers/rootly/status_page.go create mode 100644 providers/rootly/team.go create mode 100644 providers/rootly/webhooks_endpoint.go create mode 100644 providers/rootly/workflow.go create mode 100644 providers/rootly/workflow_group.go diff --git a/providers/rootly/cause.go b/providers/rootly/cause.go new file mode 100644 index 000000000..bf9586bef --- /dev/null +++ b/providers/rootly/cause.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type CauseGenerator struct { + RootlyService +} + +func (g* CauseGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListCausesParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListCauses(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createCauseResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *CauseGenerator) createCauseResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.Cause) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_cause", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/dashboard.go b/providers/rootly/dashboard.go new file mode 100644 index 000000000..fc5bf9f2b --- /dev/null +++ b/providers/rootly/dashboard.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type DashboardGenerator struct { + RootlyService +} + +func (g* DashboardGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListDashboardsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListDashboards(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createDashboardResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *DashboardGenerator) createDashboardResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.Dashboard) + return terraformutils.NewSimpleResource( + x.ID, + x.Name, + "rootly_dashboard", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/environment.go b/providers/rootly/environment.go new file mode 100644 index 000000000..b3e88b28b --- /dev/null +++ b/providers/rootly/environment.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type EnvironmentGenerator struct { + RootlyService +} + +func (g* EnvironmentGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListEnvironmentsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListEnvironments(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createEnvironmentResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *EnvironmentGenerator) createEnvironmentResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.Environment) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_environment", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/form_field.go b/providers/rootly/form_field.go new file mode 100644 index 000000000..3206b96f1 --- /dev/null +++ b/providers/rootly/form_field.go @@ -0,0 +1,204 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type FormFieldGenerator struct { + RootlyService +} + +func (g* FormFieldGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListFormFieldsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListFormFields(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createFormFieldResource(resource) + g.Resources = append(g.Resources, tf_resource) + child_form_field_option, err := g.createFormFieldOptionResources(tf_resource.InstanceState.ID) + if err != nil { + return err + } + g.Resources = append(g.Resources, child_form_field_option...) +child_form_field_position, err := g.createFormFieldPositionResources(tf_resource.InstanceState.ID) + if err != nil { + return err + } + g.Resources = append(g.Resources, child_form_field_position...) + } + + page_num += 1 + } + + return nil +} + +func (g *FormFieldGenerator) createFormFieldResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.FormField) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_form_field", + g.ProviderName, + []string{}, + ) +} + + +func (g *FormFieldGenerator) PostConvertHook() error { + for _, resource := range g.Resources { + + if resource.InstanceInfo.Type != "rootly_form_field" { + continue + } + + + for i, form_field_option := range g.Resources { + if form_field_option.InstanceInfo.Type != "rootly_form_field_option" { + continue + } + if form_field_option.InstanceState.Attributes["form_field_id"] == resource.InstanceState.ID { + g.Resources[i].Item["form_field_id"] = "${" + resource.InstanceInfo.Type + "." + resource.ResourceName + ".id}" + } + } + + + for i, form_field_position := range g.Resources { + if form_field_position.InstanceInfo.Type != "rootly_form_field_position" { + continue + } + if form_field_position.InstanceState.Attributes["form_field_id"] == resource.InstanceState.ID { + g.Resources[i].Item["form_field_id"] = "${" + resource.InstanceInfo.Type + "." + resource.ResourceName + ".id}" + } + } + + } + + return nil +} + + +func (g *FormFieldGenerator) createFormFieldOptionResources(parent_id string) ([]terraformutils.Resource, error) { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return nil, err + } + + var tf_resources []terraformutils.Resource + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListFormFieldOptionsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListFormFieldOptions(parent_id, params) + }(page_size, page_num) + + if err != nil { + return nil, err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resources = append(tf_resources, g.createFormFieldOptionResource(resource)) + } + + page_num += 1 + } + + return tf_resources, nil +} + +func (g *FormFieldGenerator) createFormFieldOptionResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.FormFieldOption) + return terraformutils.NewSimpleResource( + x.ID, + x.ID, + "rootly_form_field_option", + g.ProviderName, + []string{}, + ) +} + + +func (g *FormFieldGenerator) createFormFieldPositionResources(parent_id string) ([]terraformutils.Resource, error) { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return nil, err + } + + var tf_resources []terraformutils.Resource + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListFormFieldPositionsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListFormFieldPositions(parent_id, params) + }(page_size, page_num) + + if err != nil { + return nil, err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resources = append(tf_resources, g.createFormFieldPositionResource(resource)) + } + + page_num += 1 + } + + return tf_resources, nil +} + +func (g *FormFieldGenerator) createFormFieldPositionResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.FormFieldPosition) + return terraformutils.NewSimpleResource( + x.ID, + x.ID, + "rootly_form_field_position", + g.ProviderName, + []string{}, + ) +} + diff --git a/providers/rootly/functionality.go b/providers/rootly/functionality.go new file mode 100644 index 000000000..20ee37a10 --- /dev/null +++ b/providers/rootly/functionality.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type FunctionalityGenerator struct { + RootlyService +} + +func (g* FunctionalityGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListFunctionalitiesParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListFunctionalities(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createFunctionalityResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *FunctionalityGenerator) createFunctionalityResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.Functionality) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_functionality", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/incident_role.go b/providers/rootly/incident_role.go new file mode 100644 index 000000000..3ac851ba4 --- /dev/null +++ b/providers/rootly/incident_role.go @@ -0,0 +1,140 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type IncidentRoleGenerator struct { + RootlyService +} + +func (g* IncidentRoleGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListIncidentRolesParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListIncidentRoles(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createIncidentRoleResource(resource) + g.Resources = append(g.Resources, tf_resource) + child_incident_role_task, err := g.createIncidentRoleTaskResources(tf_resource.InstanceState.ID) + if err != nil { + return err + } + g.Resources = append(g.Resources, child_incident_role_task...) + } + + page_num += 1 + } + + return nil +} + +func (g *IncidentRoleGenerator) createIncidentRoleResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.IncidentRole) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_incident_role", + g.ProviderName, + []string{}, + ) +} + + +func (g *IncidentRoleGenerator) PostConvertHook() error { + for _, resource := range g.Resources { + + if resource.InstanceInfo.Type != "rootly_incident_role" { + continue + } + + + for i, incident_role_task := range g.Resources { + if incident_role_task.InstanceInfo.Type != "rootly_incident_role_task" { + continue + } + if incident_role_task.InstanceState.Attributes["incident_role_id"] == resource.InstanceState.ID { + g.Resources[i].Item["incident_role_id"] = "${" + resource.InstanceInfo.Type + "." + resource.ResourceName + ".id}" + } + } + + } + + return nil +} + + +func (g *IncidentRoleGenerator) createIncidentRoleTaskResources(parent_id string) ([]terraformutils.Resource, error) { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return nil, err + } + + var tf_resources []terraformutils.Resource + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListIncidentRoleTasksParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListIncidentRoleTasks(parent_id, params) + }(page_size, page_num) + + if err != nil { + return nil, err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resources = append(tf_resources, g.createIncidentRoleTaskResource(resource)) + } + + page_num += 1 + } + + return tf_resources, nil +} + +func (g *IncidentRoleGenerator) createIncidentRoleTaskResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.IncidentRoleTask) + return terraformutils.NewSimpleResource( + x.ID, + x.ID, + "rootly_incident_role_task", + g.ProviderName, + []string{}, + ) +} + diff --git a/providers/rootly/incident_type.go b/providers/rootly/incident_type.go new file mode 100644 index 000000000..96552b204 --- /dev/null +++ b/providers/rootly/incident_type.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type IncidentTypeGenerator struct { + RootlyService +} + +func (g* IncidentTypeGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListIncidentTypesParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListIncidentTypes(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createIncidentTypeResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *IncidentTypeGenerator) createIncidentTypeResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.IncidentType) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_incident_type", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/playbook.go b/providers/rootly/playbook.go new file mode 100644 index 000000000..e726b3807 --- /dev/null +++ b/providers/rootly/playbook.go @@ -0,0 +1,140 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type PlaybookGenerator struct { + RootlyService +} + +func (g* PlaybookGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListPlaybooksParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListPlaybooks(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createPlaybookResource(resource) + g.Resources = append(g.Resources, tf_resource) + child_playbook_task, err := g.createPlaybookTaskResources(tf_resource.InstanceState.ID) + if err != nil { + return err + } + g.Resources = append(g.Resources, child_playbook_task...) + } + + page_num += 1 + } + + return nil +} + +func (g *PlaybookGenerator) createPlaybookResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.Playbook) + return terraformutils.NewSimpleResource( + x.ID, + x.ID, + "rootly_playbook", + g.ProviderName, + []string{}, + ) +} + + +func (g *PlaybookGenerator) PostConvertHook() error { + for _, resource := range g.Resources { + + if resource.InstanceInfo.Type != "rootly_playbook" { + continue + } + + + for i, playbook_task := range g.Resources { + if playbook_task.InstanceInfo.Type != "rootly_playbook_task" { + continue + } + if playbook_task.InstanceState.Attributes["playbook_id"] == resource.InstanceState.ID { + g.Resources[i].Item["playbook_id"] = "${" + resource.InstanceInfo.Type + "." + resource.ResourceName + ".id}" + } + } + + } + + return nil +} + + +func (g *PlaybookGenerator) createPlaybookTaskResources(parent_id string) ([]terraformutils.Resource, error) { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return nil, err + } + + var tf_resources []terraformutils.Resource + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListPlaybookTasksParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListPlaybookTasks(parent_id, params) + }(page_size, page_num) + + if err != nil { + return nil, err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resources = append(tf_resources, g.createPlaybookTaskResource(resource)) + } + + page_num += 1 + } + + return tf_resources, nil +} + +func (g *PlaybookGenerator) createPlaybookTaskResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.PlaybookTask) + return terraformutils.NewSimpleResource( + x.ID, + x.ID, + "rootly_playbook_task", + g.ProviderName, + []string{}, + ) +} + diff --git a/providers/rootly/post_mortem_template.go b/providers/rootly/post_mortem_template.go new file mode 100644 index 000000000..394e0924f --- /dev/null +++ b/providers/rootly/post_mortem_template.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type PostMortemTemplateGenerator struct { + RootlyService +} + +func (g* PostMortemTemplateGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListPostmortemTemplatesParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListPostmortemTemplates(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createPostMortemTemplateResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *PostMortemTemplateGenerator) createPostMortemTemplateResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.PostmortemTemplate) + return terraformutils.NewSimpleResource( + x.ID, + x.Name, + "rootly_post_mortem_template", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/retrospective_step.go b/providers/rootly/retrospective_step.go new file mode 100644 index 000000000..e64668049 --- /dev/null +++ b/providers/rootly/retrospective_step.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type RetrospectiveStepGenerator struct { + RootlyService +} + +func (g* RetrospectiveStepGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListRetrospectiveStepsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListRetrospectiveSteps(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createRetrospectiveStepResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *RetrospectiveStepGenerator) createRetrospectiveStepResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.RetrospectiveStep) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_retrospective_step", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/rootly_provider.go b/providers/rootly/rootly_provider.go index 3d593deb1..1fad9509f 100644 --- a/providers/rootly/rootly_provider.go +++ b/providers/rootly/rootly_provider.go @@ -21,6 +21,9 @@ func (p *RootlyProvider) Init(args []string) error { if args[0] != "" { p.apiUrl = args[0] } + if p.apiUrl == "" { + p.apiUrl = "https://api.rootly.com" + } if apiKey := os.Getenv("ROOTLY_API_TOKEN"); apiKey != "" { p.apiKey = os.Getenv("ROOTLY_API_TOKEN") diff --git a/providers/rootly/secret.go b/providers/rootly/secret.go new file mode 100644 index 000000000..a5bbaf40b --- /dev/null +++ b/providers/rootly/secret.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type SecretGenerator struct { + RootlyService +} + +func (g* SecretGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListSecretsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListSecrets(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createSecretResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *SecretGenerator) createSecretResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.Secret) + return terraformutils.NewSimpleResource( + x.ID, + x.Name, + "rootly_secret", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/service.go b/providers/rootly/service.go new file mode 100644 index 000000000..4faf763e7 --- /dev/null +++ b/providers/rootly/service.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type ServiceGenerator struct { + RootlyService +} + +func (g* ServiceGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListServicesParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListServices(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createServiceResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *ServiceGenerator) createServiceResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.Service) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_service", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/severity.go b/providers/rootly/severity.go new file mode 100644 index 000000000..29627c2e7 --- /dev/null +++ b/providers/rootly/severity.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type SeverityGenerator struct { + RootlyService +} + +func (g* SeverityGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListSeveritiesParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListSeverities(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createSeverityResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *SeverityGenerator) createSeverityResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.Severity) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_severity", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/status_page.go b/providers/rootly/status_page.go new file mode 100644 index 000000000..e33343de6 --- /dev/null +++ b/providers/rootly/status_page.go @@ -0,0 +1,140 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type StatusPageGenerator struct { + RootlyService +} + +func (g* StatusPageGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListStatusPagesParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListStatusPages(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createStatusPageResource(resource) + g.Resources = append(g.Resources, tf_resource) + child_status_page_template, err := g.createStatusPageTemplateResources(tf_resource.InstanceState.ID) + if err != nil { + return err + } + g.Resources = append(g.Resources, child_status_page_template...) + } + + page_num += 1 + } + + return nil +} + +func (g *StatusPageGenerator) createStatusPageResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.StatusPage) + return terraformutils.NewSimpleResource( + x.ID, + x.ID, + "rootly_status_page", + g.ProviderName, + []string{}, + ) +} + + +func (g *StatusPageGenerator) PostConvertHook() error { + for _, resource := range g.Resources { + + if resource.InstanceInfo.Type != "rootly_status_page" { + continue + } + + + for i, status_page_template := range g.Resources { + if status_page_template.InstanceInfo.Type != "rootly_status_page_template" { + continue + } + if status_page_template.InstanceState.Attributes["status_page_id"] == resource.InstanceState.ID { + g.Resources[i].Item["status_page_id"] = "${" + resource.InstanceInfo.Type + "." + resource.ResourceName + ".id}" + } + } + + } + + return nil +} + + +func (g *StatusPageGenerator) createStatusPageTemplateResources(parent_id string) ([]terraformutils.Resource, error) { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return nil, err + } + + var tf_resources []terraformutils.Resource + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListStatusPageTemplatesParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListStatusPageTemplates(parent_id, params) + }(page_size, page_num) + + if err != nil { + return nil, err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resources = append(tf_resources, g.createStatusPageTemplateResource(resource)) + } + + page_num += 1 + } + + return tf_resources, nil +} + +func (g *StatusPageGenerator) createStatusPageTemplateResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.StatusPageTemplate) + return terraformutils.NewSimpleResource( + x.ID, + x.ID, + "rootly_status_page_template", + g.ProviderName, + []string{}, + ) +} + diff --git a/providers/rootly/team.go b/providers/rootly/team.go new file mode 100644 index 000000000..34756c1d3 --- /dev/null +++ b/providers/rootly/team.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type TeamGenerator struct { + RootlyService +} + +func (g* TeamGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListTeamsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListTeams(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createTeamResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *TeamGenerator) createTeamResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.Team) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_team", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/webhooks_endpoint.go b/providers/rootly/webhooks_endpoint.go new file mode 100644 index 000000000..d98de3554 --- /dev/null +++ b/providers/rootly/webhooks_endpoint.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type WebhooksEndpointGenerator struct { + RootlyService +} + +func (g* WebhooksEndpointGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListWebhooksEndpointsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListWebhooksEndpoints(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createWebhooksEndpointResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *WebhooksEndpointGenerator) createWebhooksEndpointResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.WebhooksEndpoint) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_webhooks_endpoint", + g.ProviderName, + []string{}, + ) +} + + + + diff --git a/providers/rootly/workflow.go b/providers/rootly/workflow.go new file mode 100644 index 000000000..2e07051d5 --- /dev/null +++ b/providers/rootly/workflow.go @@ -0,0 +1,268 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + "regexp" + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type WorkflowGenerator struct { + RootlyService +} + +func (g* WorkflowGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListWorkflowsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListWorkflows(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createWorkflowResource(resource) + g.Resources = append(g.Resources, tf_resource) + child_workflow_custom_field_selection, err := g.createWorkflowCustomFieldSelectionResources(tf_resource.InstanceState.ID) + if err != nil { + return err + } + g.Resources = append(g.Resources, child_workflow_custom_field_selection...) +child_workflow_form_field_condition, err := g.createWorkflowFormFieldConditionResources(tf_resource.InstanceState.ID) + if err != nil { + return err + } + g.Resources = append(g.Resources, child_workflow_form_field_condition...) +child_workflow_task, err := g.createWorkflowTaskResources(tf_resource.InstanceState.ID) + if err != nil { + return err + } + g.Resources = append(g.Resources, child_workflow_task...) + } + + page_num += 1 + } + + return nil +} + +func (g *WorkflowGenerator) createWorkflowResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.Workflow) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_workflow_" + x.TriggerParams["trigger_type"].(string), + g.ProviderName, + []string{}, + ) +} + + +func (g *WorkflowGenerator) PostConvertHook() error { + for _, resource := range g.Resources { + + if resource.InstanceInfo.Type != "rootly_workflow_incident" && resource.InstanceInfo.Type != "rootly_workflow_action_item" && resource.InstanceInfo.Type != "rootly_workflow_post_mortem" && resource.InstanceInfo.Type != "rootly_workflow_pulse" && resource.InstanceInfo.Type != "rootly_workflow_alert" && resource.InstanceInfo.Type != "rootly_workflow_simple" { + continue + } + + + for i, workflow_custom_field_selection := range g.Resources { + if workflow_custom_field_selection.InstanceInfo.Type != "rootly_workflow_custom_field_selection" { + continue + } + if workflow_custom_field_selection.InstanceState.Attributes["workflow_id"] == resource.InstanceState.ID { + g.Resources[i].Item["workflow_id"] = "${" + resource.InstanceInfo.Type + "." + resource.ResourceName + ".id}" + } + } + + + for i, workflow_form_field_condition := range g.Resources { + if workflow_form_field_condition.InstanceInfo.Type != "rootly_workflow_form_field_condition" { + continue + } + if workflow_form_field_condition.InstanceState.Attributes["workflow_id"] == resource.InstanceState.ID { + g.Resources[i].Item["workflow_id"] = "${" + resource.InstanceInfo.Type + "." + resource.ResourceName + ".id}" + } + } + + + for i, workflow_task := range g.Resources { + if !regexp.MustCompile(`workflow_task`).MatchString(workflow_task.InstanceInfo.Type) { + continue + } + if workflow_task.InstanceState.Attributes["workflow_id"] == resource.InstanceState.ID { + g.Resources[i].Item["workflow_id"] = "${" + resource.InstanceInfo.Type + "." + resource.ResourceName + ".id}" + } + } + + } + + return nil +} + + +func (g *WorkflowGenerator) createWorkflowCustomFieldSelectionResources(parent_id string) ([]terraformutils.Resource, error) { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return nil, err + } + + var tf_resources []terraformutils.Resource + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListWorkflowCustomFieldSelectionsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListWorkflowCustomFieldSelections(parent_id, params) + }(page_size, page_num) + + if err != nil { + return nil, err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resources = append(tf_resources, g.createWorkflowCustomFieldSelectionResource(resource)) + } + + page_num += 1 + } + + return tf_resources, nil +} + +func (g *WorkflowGenerator) createWorkflowCustomFieldSelectionResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.WorkflowCustomFieldSelection) + return terraformutils.NewSimpleResource( + x.ID, + x.ID, + "rootly_workflow_custom_field_selection", + g.ProviderName, + []string{}, + ) +} + + +func (g *WorkflowGenerator) createWorkflowFormFieldConditionResources(parent_id string) ([]terraformutils.Resource, error) { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return nil, err + } + + var tf_resources []terraformutils.Resource + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListWorkflowFormFieldConditionsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListWorkflowFormFieldConditions(parent_id, params) + }(page_size, page_num) + + if err != nil { + return nil, err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resources = append(tf_resources, g.createWorkflowFormFieldConditionResource(resource)) + } + + page_num += 1 + } + + return tf_resources, nil +} + +func (g *WorkflowGenerator) createWorkflowFormFieldConditionResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.WorkflowFormFieldCondition) + return terraformutils.NewSimpleResource( + x.ID, + x.ID, + "rootly_workflow_form_field_condition", + g.ProviderName, + []string{}, + ) +} + + +func (g *WorkflowGenerator) createWorkflowTaskResources(parent_id string) ([]terraformutils.Resource, error) { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return nil, err + } + + var tf_resources []terraformutils.Resource + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListWorkflowTasksParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListWorkflowTasks(parent_id, params) + }(page_size, page_num) + + if err != nil { + return nil, err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resources = append(tf_resources, g.createWorkflowTaskResource(resource)) + } + + page_num += 1 + } + + return tf_resources, nil +} + +func (g *WorkflowGenerator) createWorkflowTaskResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.WorkflowTask) + return terraformutils.NewSimpleResource( + x.ID, + x.Name, + "rootly_workflow_task_" + x.TaskParams["task_type"].(string), + g.ProviderName, + []string{}, + ) +} + diff --git a/providers/rootly/workflow_group.go b/providers/rootly/workflow_group.go new file mode 100644 index 000000000..e75058089 --- /dev/null +++ b/providers/rootly/workflow_group.go @@ -0,0 +1,67 @@ + +// Generated by generators/rootly/rootly.js + +package rootly + +import ( + + "github.com/GoogleCloudPlatform/terraformer/terraformutils" + "github.com/rootlyhq/terraform-provider-rootly/client" + rootlygo "github.com/rootlyhq/terraform-provider-rootly/schema" +) + +type WorkflowGroupGenerator struct { + RootlyService +} + +func (g* WorkflowGroupGenerator) InitResources() error { + page_size := 50 + page_num := 1 + + client, err := g.RootlyClient() + if err != nil { + return err + } + + for { + resources, err := func(page_size, page_num int) ([]interface{}, error) { + params := new(rootlygo.ListWorkflowGroupsParams) + params.PageSize = &page_size + params.PageNumber = &page_num + return client.ListWorkflowGroups(params) + }(page_size, page_num) + + if err != nil { + return err + } + + if len(resources) == 0 { + break + } + + for _, resource := range resources { + tf_resource := g.createWorkflowGroupResource(resource) + g.Resources = append(g.Resources, tf_resource) + + } + + page_num += 1 + } + + return nil +} + +func (g *WorkflowGroupGenerator) createWorkflowGroupResource(provider_resource interface{}) terraformutils.Resource { + x, _ := provider_resource.(*client.WorkflowGroup) + return terraformutils.NewSimpleResource( + x.ID, + x.Slug, + "rootly_workflow_group", + g.ProviderName, + []string{}, + ) +} + + + +