azure-loganalytics-datacollector-api 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +3 -0
- data/azure-loganalytics-datacollector-api.gemspec +1 -1
- data/lib/azure/loganalytics/datacollectorapi/client.rb +3 -3
- data/lib/azure/loganalytics/datacollectorapi/version.rb +1 -1
- data/spec/azure/loganalytics/datacollectorapi/client_spec.rb +25 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8452aaabdb1e4cadea593892598d3618d72d4dc268b73612a8072b98bb144a29
|
4
|
+
data.tar.gz: c095ecb8502f5afcc742e1cfa7da6c5b4d4f59522dab871323761a45ba6f4af3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 710358fb3591f079e96ba0c4e26ba020ee5573dc3c27553883efa80dd62943a3dcde86c7e0dbb1d0ee5d1a20bdf28ea554be8fd2a7df64423088189492f07501
|
7
|
+
data.tar.gz: 523e5be5872c7450e8518835cf18e674043e5578e1b95588ea74070af40dce53418aaa455badeb2b156af9223e97228172bbb3af4e3ec8f4ea9ee2bef411eafd
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 0.3.0
|
2
|
+
* Enhance log type validation: check not only alpha but also numeric, underscore, and character length (may not exceed 100) - [issue #11](https://github.com/yokawasa/azure-log-analytics-data-collector/issues/11)
|
3
|
+
|
1
4
|
## 0.2.0
|
2
5
|
* Support setting the x-ms-AzureResourceId Header - [issue #8](https://github.com/yokawasa/azure-log-analytics-data-collector/issues/8)
|
3
6
|
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "azure-loganalytics-datacollector-api"
|
8
8
|
spec.version = Azure::Loganalytics::Datacollectorapi::VERSION
|
9
9
|
spec.authors = ["Yoichi Kawasaki"]
|
10
|
-
spec.email = ["
|
10
|
+
spec.email = ["yokawasa@gmail.com"]
|
11
11
|
spec.summary = %q{Azure Log Analytics Data Collector API Ruby Client}
|
12
12
|
spec.description = spec.summary
|
13
13
|
spec.homepage = "https://github.com/yokawasa/azure-log-analytics-data-collector"
|
@@ -23,7 +23,7 @@ module Azure
|
|
23
23
|
|
24
24
|
def post_data(log_type, json_records, record_timestamp ='', azure_resource_id ='' )
|
25
25
|
raise ConfigError, 'no log_type' if log_type.empty?
|
26
|
-
raise ConfigError, 'log_type must
|
26
|
+
raise ConfigError, 'log_type must only contain alpha numeric and _, and not exceed 100 chars' if not is_valid_log_type(log_type)
|
27
27
|
raise ConfigError, 'no json_records' if json_records.empty?
|
28
28
|
body = json_records.to_json
|
29
29
|
uri = sprintf("https://%s.%s/api/logs?api-version=%s",
|
@@ -58,8 +58,8 @@ module Azure
|
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
|
-
def
|
62
|
-
return (s.match(/^[
|
61
|
+
def is_valid_log_type(s)
|
62
|
+
return ( s.match(/^[a-zA-Z0-9_]+$/) && s.length <= 100 ) ? true : false
|
63
63
|
end
|
64
64
|
|
65
65
|
def rfc1123date()
|
@@ -5,14 +5,35 @@ describe Azure::Loganalytics::Datacollectorapi::Client do
|
|
5
5
|
expect(Azure::Loganalytics::Datacollectorapi::VERSION).not_to be nil
|
6
6
|
end
|
7
7
|
|
8
|
-
#it "does something useful" do
|
9
|
-
# expect(false).to eq(true)
|
10
|
-
#end
|
11
|
-
|
12
8
|
customer_id = '<Customer ID aka WorkspaceID String>'
|
13
9
|
shared_key = '<Primary Key String>'
|
14
10
|
log_type = "MyCustomLog"
|
15
11
|
|
12
|
+
it "log type validation" do
|
13
|
+
json_records = []
|
14
|
+
dummy= {
|
15
|
+
:string => "dummy title",
|
16
|
+
:number => 10
|
17
|
+
}
|
18
|
+
valid_log_type = "abcedefghijklmnopqrstuvwxyz1234567890_"
|
19
|
+
invalid_log_type1 = "*-|[]//"
|
20
|
+
invalid_log_type2 = "abcde__xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
21
|
+
json_records.push(dummy)
|
22
|
+
client=Azure::Loganalytics::Datacollectorapi::Client::new( customer_id, shared_key)
|
23
|
+
|
24
|
+
res = client.post_data(valid_log_type, json_records)
|
25
|
+
expect(Azure::Loganalytics::Datacollectorapi::Client.is_success(res)).to eq(true)
|
26
|
+
|
27
|
+
expect{
|
28
|
+
client.post_data(invalid_log_type1, json_records)
|
29
|
+
}.to raise_error(Exception)
|
30
|
+
|
31
|
+
expect{
|
32
|
+
client.post_data(invalid_log_type2, json_records)
|
33
|
+
}.to raise_error(Exception)
|
34
|
+
|
35
|
+
end
|
36
|
+
|
16
37
|
it "posting data to datacollector api" do
|
17
38
|
json_records = []
|
18
39
|
record1= {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azure-loganalytics-datacollector-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoichi Kawasaki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '3.0'
|
55
55
|
description: Azure Log Analytics Data Collector API Ruby Client
|
56
56
|
email:
|
57
|
-
-
|
57
|
+
- yokawasa@gmail.com
|
58
58
|
executables:
|
59
59
|
- console
|
60
60
|
- setup
|