From e1191c41094df997ac320b6b4491cf4ae645c46a Mon Sep 17 00:00:00 2001 From: Holden Omans Date: Fri, 12 Jul 2019 10:27:27 -0400 Subject: [PATCH 1/4] add missing fields for datasources --- datasource.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/datasource.go b/datasource.go index a5b40de..c9c759e 100644 --- a/datasource.go +++ b/datasource.go @@ -36,7 +36,11 @@ type JSONData struct { AuthType string `json:"authType,omitempty"` CustomMetricsNamespaces string `json:"customMetricsNamespaces,omitempty"` DefaultRegion string `json:"defaultRegion,omitempty"` - TlsSkipVerify bool `json:"tlsSkipVerify,omitempty"` + EsVersion int64 `json:esVersion,omitempty` + TlsSkipVerify bool `json:"tlsSkipVerify,omitempty"` + HttpMethod string `json:httpMethod,omitempty` + QueryTimeout string `json:queryTimeout,omitempty` + TimeInterval string `json:timeInterval,omitempty` } // SecureJSONData is a representation of the datasource `secureJsonData` property From 128f17e6c3d9a109579b72d12009119040239833 Mon Sep 17 00:00:00 2001 From: Holden Omans Date: Fri, 12 Jul 2019 10:34:45 -0400 Subject: [PATCH 2/4] remove EsVersion --- datasource.go | 1 - 1 file changed, 1 deletion(-) diff --git a/datasource.go b/datasource.go index c9c759e..a25d3f9 100644 --- a/datasource.go +++ b/datasource.go @@ -36,7 +36,6 @@ type JSONData struct { AuthType string `json:"authType,omitempty"` CustomMetricsNamespaces string `json:"customMetricsNamespaces,omitempty"` DefaultRegion string `json:"defaultRegion,omitempty"` - EsVersion int64 `json:esVersion,omitempty` TlsSkipVerify bool `json:"tlsSkipVerify,omitempty"` HttpMethod string `json:httpMethod,omitempty` QueryTimeout string `json:queryTimeout,omitempty` From 9d3ff1ed93f4df51850b88af9b2e92a757c54c62 Mon Sep 17 00:00:00 2001 From: Holden Omans Date: Fri, 12 Jul 2019 11:46:31 -0400 Subject: [PATCH 3/4] added test and corrected json syntax --- .gitignore | 1 + datasource.go | 8 ++++---- datasource_test.go | 31 +++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b98422d..c26eb63 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ _testmain.go # vim swap files .*.sw? +.idea \ No newline at end of file diff --git a/datasource.go b/datasource.go index a25d3f9..e4673b8 100644 --- a/datasource.go +++ b/datasource.go @@ -36,10 +36,10 @@ type JSONData struct { AuthType string `json:"authType,omitempty"` CustomMetricsNamespaces string `json:"customMetricsNamespaces,omitempty"` DefaultRegion string `json:"defaultRegion,omitempty"` - TlsSkipVerify bool `json:"tlsSkipVerify,omitempty"` - HttpMethod string `json:httpMethod,omitempty` - QueryTimeout string `json:queryTimeout,omitempty` - TimeInterval string `json:timeInterval,omitempty` + TlsSkipVerify bool `json:"tlsSkipVerify,omitempty"` + HttpMethod string `json:"httpMethod,omitempty"` + QueryTimeout string `json:"queryTimeout,omitempty"` + TimeInterval string `json:"timeInterval,omitempty"` } // SecureJSONData is a representation of the datasource `secureJsonData` property diff --git a/datasource_test.go b/datasource_test.go index c2ee1b7..be59859 100644 --- a/datasource_test.go +++ b/datasource_test.go @@ -73,3 +73,34 @@ func TestNewDataSource(t *testing.T) { t.Error("datasource creation response should return the created datasource ID") } } + +func TestNewPrometheusDataSource(t *testing.T) { + server, client := gapiTestTools(200, createdDataSourceJSON) + defer server.Close() + //client_acc, _ := New("admin:admin", "http://localhost:3000") + + ds := &DataSource{ + Name: "foo_prometheus", + Type: "prometheus", + URL: "http://some-url.com", + Access: "access", + IsDefault: true, + JSONData: JSONData{ + HttpMethod: "POST", + QueryTimeout: "60s", + TimeInterval: "1m", + }, + } + + created, err := client.NewDataSource(ds) + //created, err := client_acc.NewDataSource(ds) + if err != nil { + t.Error(err) + } + + t.Log(pretty.PrettyFormat(created)) + + if created != 1 { + t.Error("datasource creation response should return the created datasource ID") + } +} From ca08724cc176b114881bc1e03dcf486ee2a9ab3a Mon Sep 17 00:00:00 2001 From: Holden Omans Date: Thu, 3 Oct 2019 07:34:39 -0400 Subject: [PATCH 4/4] Update datasource_test.go --- datasource_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/datasource_test.go b/datasource_test.go index be59859..4988719 100644 --- a/datasource_test.go +++ b/datasource_test.go @@ -77,7 +77,6 @@ func TestNewDataSource(t *testing.T) { func TestNewPrometheusDataSource(t *testing.T) { server, client := gapiTestTools(200, createdDataSourceJSON) defer server.Close() - //client_acc, _ := New("admin:admin", "http://localhost:3000") ds := &DataSource{ Name: "foo_prometheus", @@ -93,7 +92,6 @@ func TestNewPrometheusDataSource(t *testing.T) { } created, err := client.NewDataSource(ds) - //created, err := client_acc.NewDataSource(ds) if err != nil { t.Error(err) }