github.com/GoogleCloudPlatform/terraformer@v0.8.18/providers/rabbitmq/rabbitmq_service.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 rabbitmq 16 17 import ( 18 "io/ioutil" 19 "net/http" 20 21 "github.com/GoogleCloudPlatform/terraformer/terraformutils" 22 ) 23 24 type RBTService struct { //nolint 25 terraformutils.Service 26 } 27 28 func (s *RBTService) generateRequest(uri string) ([]byte, error) { 29 tr := &http.Transport{} 30 client := &http.Client{Transport: tr} 31 req, err := http.NewRequest("GET", s.Args["endpoint"].(string)+uri, nil) 32 if err != nil { 33 return nil, err 34 } 35 req.SetBasicAuth(s.Args["username"].(string), s.Args["password"].(string)) 36 resp, err := client.Do(req) 37 if err != nil { 38 return nil, err 39 } 40 defer resp.Body.Close() 41 body, err := ioutil.ReadAll(resp.Body) 42 if err != nil { 43 return nil, err 44 } 45 return body, nil 46 }