This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the following resources: * pingdom_team * pingdom_user * pingdom_contact Adds parameters to existing resource: * pingdom_check: adds responsetime_threshold
- Loading branch information
1 parent
ad4bbfd
commit 82b3c75
Showing
17 changed files
with
780 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/terraform-provider-pingdom | ||
/.terraform | ||
|
||
examples/*.tfstate* | ||
examples/*.tfstate.backup | ||
examples/*.tfvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Pingdom Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright (C) 2018-2019 Nicolas Lamirault <nicolas.lamirault@gmail.com> | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
terraform { | ||
required_version = ">= 0.11.0" | ||
} | ||
|
||
resource "pingdom_team" "test_one" { | ||
name = "Team 1 (updated by Terraform)" | ||
} | ||
|
||
provider "pingdom" { | ||
user = "${var.pingdom_user}" | ||
password = "${var.pingdom_password}" | ||
api_key = "${var.pingdom_api_key}" | ||
} | ||
|
||
resource "pingdom_team" "test" { | ||
name = "Team for testing" | ||
} | ||
|
||
resource "pingdom_user" "first_user" { | ||
username = "johndoe" | ||
} | ||
|
||
resource "pingdom_contact" "first_user_contact_email_1" { | ||
user_id = "${pingdom_user.first_user.id}" | ||
email = "john@doe.com" | ||
severity_level = "HIGH" | ||
} | ||
|
||
resource "pingdom_contact" "first_user_contact_email_2" { | ||
user_id = "${pingdom_user.first_user.id}" | ||
email = "john.doe@doe.com" | ||
severity_level = "LOW" | ||
} | ||
|
||
resource "pingdom_contact" "first_user_contact_sms_1" { | ||
user_id = "${pingdom_user.first_user.id}" | ||
number = "700000000" | ||
country_code = "33" | ||
phone_provider = "nexmo" | ||
severity_level = "HIGH" | ||
} | ||
|
||
resource "pingdom_user" "second_user" { | ||
username = "janedoe" | ||
} | ||
|
||
resource "pingdom_contact" "second_user_contact_email_1" { | ||
user_id = "${pingdom_user.second_user.id}" | ||
email = "jane@doe.com" | ||
severity_level = "high" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
variable "pingdom_user" {} | ||
|
||
variable "pingdom_password" {} | ||
|
||
variable "pingdom_api_key" { | ||
description = "The API key to used" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package pingdom | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/hashicorp/terraform/helper/schema" | ||
"github.com/russellcardullo/go-pingdom/pingdom" | ||
) | ||
|
||
func dataSourcePingdomUser() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourcePingdomUserRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"username": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourcePingdomUserRead(d *schema.ResourceData, meta interface{}) error { | ||
client := meta.(*pingdom.Client) | ||
username := d.Get("username").(string) | ||
users, err := client.Users.List() | ||
log.Printf("==== users : %v", users) | ||
if err != nil { | ||
return fmt.Errorf("Error retrieving user: %s", err) | ||
} | ||
var found pingdom.UsersResponse | ||
for _, user := range users { | ||
if user.Username == username { | ||
log.Printf("User: %v", user) | ||
found = user | ||
} | ||
} | ||
d.Set("username", found.Username) | ||
d.SetId(fmt.Sprintf("%d", found.Id)) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.