github.com/GoogleCloudPlatform/terraformer@v0.8.18/providers/logzio/alert_notification_endpoints.go (about) 1 // Copyright 2018 The Terraformer Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package logzio 16 17 import ( 18 "strconv" 19 20 "github.com/GoogleCloudPlatform/terraformer/terraformutils" 21 22 "github.com/jonboydell/logzio_client/endpoints" 23 ) 24 25 type AlertNotificationEndpointsGenerator struct { 26 LogzioService 27 } 28 29 // Generate Terraform Resources from Logzio API, 30 func (g *AlertNotificationEndpointsGenerator) InitResources() error { 31 var client *endpoints.EndpointsClient 32 client, _ = endpoints.New(g.Args["api_token"].(string), g.Args["base_url"].(string)) 33 34 endpoints, err := client.ListEndpoints() 35 if err != nil { 36 return err 37 } 38 for _, endpoint := range endpoints { 39 g.Resources = append(g.Resources, terraformutils.NewSimpleResource( 40 strconv.FormatInt(endpoint.Id, 10), 41 createSlug(endpoint.Title+"-"+string(endpoint.EndpointType)+"-"+strconv.FormatInt(endpoint.Id, 10)), 42 "logzio_endpoint", 43 "logzio", 44 []string{}, 45 )) 46 } 47 return nil 48 }