77 "fmt"
88 "io"
99 "io/ioutil"
10- "log"
1110 "net/http"
1211 "net/url"
1312 "time"
@@ -29,16 +28,15 @@ type Client struct {
2928var ProviderVersion string
3029
3130var endpoints = map [string ]string {
32- "us1" : "https://api.sumologic.com/api/" ,
33- "us2" : "https://api.us2.sumologic.com/api/" ,
34- "fed" : "https://api.fed.sumologic.com/api/" ,
35- "eu" : "https://api.eu.sumologic.com/api/" ,
36- "au" : "https://api.au.sumologic.com/api/" ,
37- "de" : "https://api.de.sumologic.com/api/" ,
38- "jp" : "https://api.jp.sumologic.com/api/" ,
39- "ca" : "https://api.ca.sumologic.com/api/" ,
40- "in" : "https://api.in.sumologic.com/api/" ,
41- "nite" : "https://nite-api.sumologic.net/api/" ,
31+ "us1" : "https://api.sumologic.com/api/" ,
32+ "us2" : "https://api.us2.sumologic.com/api/" ,
33+ "fed" : "https://api.fed.sumologic.com/api/" ,
34+ "eu" : "https://api.eu.sumologic.com/api/" ,
35+ "au" : "https://api.au.sumologic.com/api/" ,
36+ "de" : "https://api.de.sumologic.com/api/" ,
37+ "jp" : "https://api.jp.sumologic.com/api/" ,
38+ "ca" : "https://api.ca.sumologic.com/api/" ,
39+ "in" : "https://api.in.sumologic.com/api/" ,
4240}
4341
4442var rateLimiter = time .NewTicker (time .Minute / 240 )
@@ -134,10 +132,8 @@ func (s *Client) GetWithCookies(urlPath string, cookies []*http.Cookie) ([]byte,
134132func (s * Client ) Post (urlPath string , payload interface {}) ([]byte , error ) {
135133 relativeURL , _ := url .Parse (urlPath )
136134 sumoURL := s .BaseURL .ResolveReference (relativeURL )
137- log .Printf ("[INFO] Post URL: %s" , sumoURL )
138- body , _ := json .Marshal (payload )
139135
140- log . Printf ( "[INFO] POST body: %s" , body )
136+ body , _ := json . Marshal ( payload )
141137 req , err := createNewRequest (http .MethodPost , sumoURL .String (), bytes .NewBuffer (body ), s .AccessID , s .AccessKey )
142138 if err != nil {
143139 return nil , err
@@ -193,12 +189,10 @@ func (s *Client) PostRawPayload(urlPath string, payload string) ([]byte, error)
193189func (s * Client ) Put (urlPath string , payload interface {}) ([]byte , error ) {
194190 relativeURL , _ := url .Parse (urlPath )
195191 sumoURL := s .BaseURL .ResolveReference (relativeURL )
196- log . Printf ( "[INFO] Put URL: %s" , sumoURL )
192+
197193 _ , etag , _ := s .Get (sumoURL .String ())
198194
199195 body , _ := json .Marshal (payload )
200-
201- log .Printf ("[INFO] PUT body: %s" , body )
202196 req , err := createNewRequest (http .MethodPut , sumoURL .String (), bytes .NewBuffer (body ), s .AccessID , s .AccessKey )
203197 if err != nil {
204198 return nil , err
@@ -231,7 +225,7 @@ func (s *Client) Put(urlPath string, payload interface{}) ([]byte, error) {
231225func (s * Client ) Get (urlPath string ) ([]byte , string , error ) {
232226 relativeURL , _ := url .Parse (urlPath )
233227 sumoURL := s .BaseURL .ResolveReference (relativeURL )
234- log . Printf ( "[INFO] Get URL: %s" , sumoURL )
228+
235229 req , err := createNewRequest (http .MethodGet , sumoURL .String (), nil , s .AccessID , s .AccessKey )
236230 if err != nil {
237231 return nil , "" , err
@@ -252,7 +246,7 @@ func (s *Client) Get(urlPath string) ([]byte, string, error) {
252246 if err != nil {
253247 return nil , "" , err
254248 }
255- log . Printf ( "[INFO] Get response: %s" , string ( d ))
249+
256250 if resp .StatusCode == 404 {
257251 return nil , "" , nil
258252 } else if resp .StatusCode >= 400 {
@@ -265,7 +259,7 @@ func (s *Client) Get(urlPath string) ([]byte, string, error) {
265259func (s * Client ) Delete (urlPath string ) ([]byte , error ) {
266260 relativeURL , _ := url .Parse (urlPath )
267261 sumoURL := s .BaseURL .ResolveReference (relativeURL )
268- log . Printf ( "[INFO] Delete URL: %s" , sumoURL )
262+
269263 req , err := createNewRequest (http .MethodDelete , sumoURL .String (), nil , s .AccessID , s .AccessKey )
270264 if err != nil {
271265 return nil , err
0 commit comments