embulk-input-zendesk_guide 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +3 -0
- data/embulk-input-zendesk_guide.gemspec +20 -0
- data/lib/embulk/input/zendesk_guide.rb +57 -0
- data/lib/embulk/input/zendesk_guide/articles.rb +75 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2a556a287bc7d20ad2d86839c23d4a921db47d22
|
4
|
+
data.tar.gz: 38c8f19a1b2df84fbdd33e72a7e64791531d1728
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6449a444dfc0ef9028daf4fd56d7dbf9e7e6f56b9a591cfcb3392d0a147177c7cab45377db966711550ea6cef02a6cae5489327ce6d19e6545da4dcbcb59dc6
|
7
|
+
data.tar.gz: 245b6695e77b9791aa7dffbbba81be4b4e048890f1824d4ce82d320022a759a6983e2319237bea890d39451e3c6e7a8b6a7fa594e38b4d7f0ef85e4563938c1c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
MIT License
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Zendesk Guide input plugin for Embulk
|
2
|
+
|
3
|
+
Embulk input plugin of [Zendesk Guide](https://developer.zendesk.com/rest_api/docs/help_center/introduction) (Help Center).
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
* **Plugin type**: input
|
8
|
+
* **Resume supported**: no
|
9
|
+
* **Cleanup supported**: no
|
10
|
+
* **Guess supported**: no
|
11
|
+
|
12
|
+
## Configuration
|
13
|
+
|
14
|
+
- **url**: URL for Zendesk Guide API (string, required)
|
15
|
+
- **username**: username to use api (string, required)
|
16
|
+
- **token**: Token (string, required)
|
17
|
+
|
18
|
+
## Example
|
19
|
+
|
20
|
+
```yaml
|
21
|
+
in:
|
22
|
+
type: zendesk_guide
|
23
|
+
url: https://support.example.com/api/v2
|
24
|
+
username: user@example.com
|
25
|
+
token: xxx
|
26
|
+
out:
|
27
|
+
type: stdout
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
## Build
|
32
|
+
|
33
|
+
```
|
34
|
+
$ rake
|
35
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = "embulk-input-zendesk_guide"
|
4
|
+
spec.version = "0.1.0"
|
5
|
+
spec.authors = ["Yasuhisa Yoshida"]
|
6
|
+
spec.summary = "Zendesk Guide input plugin for Embulk"
|
7
|
+
spec.description = "Loads records from Zendesk Guide."
|
8
|
+
spec.email = ["syou6162@gmail.com"]
|
9
|
+
spec.licenses = ["MIT"]
|
10
|
+
spec.homepage = "https://github.com/syou6162/embulk-input-zendesk_guide"
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
#spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
|
17
|
+
spec.add_development_dependency 'embulk', ['>= 0.9.23']
|
18
|
+
spec.add_development_dependency 'bundler', ['>= 1.10.6']
|
19
|
+
spec.add_development_dependency 'rake', ['>= 10.0']
|
20
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require 'date'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
require_relative 'zendesk_guide/articles'
|
6
|
+
|
7
|
+
module Embulk
|
8
|
+
module Input
|
9
|
+
class ZendeskGuide < InputPlugin
|
10
|
+
Plugin.register_input("zendesk_guide", self)
|
11
|
+
|
12
|
+
def self.transaction(config, &control)
|
13
|
+
# configuration code:
|
14
|
+
task = {
|
15
|
+
"url" => config.param("url", :string),
|
16
|
+
"username" => config.param("username", :string),
|
17
|
+
"token" => config.param("token", :string),
|
18
|
+
}
|
19
|
+
columns = Articles.columns
|
20
|
+
resume(task, columns, 1, &control)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.resume(task, columns, count, &control)
|
24
|
+
task_reports = yield(task, columns, count)
|
25
|
+
|
26
|
+
next_config_diff = {}
|
27
|
+
return next_config_diff
|
28
|
+
end
|
29
|
+
|
30
|
+
# TODO
|
31
|
+
# def self.guess(config)
|
32
|
+
# sample_records = [
|
33
|
+
# {"example"=>"a", "column"=>1, "value"=>0.1},
|
34
|
+
# {"example"=>"a", "column"=>2, "value"=>0.2},
|
35
|
+
# ]
|
36
|
+
# columns = Guess::SchemaGuess.from_hash_records(sample_records)
|
37
|
+
# return {"columns" => columns}
|
38
|
+
# end
|
39
|
+
|
40
|
+
def init
|
41
|
+
@articles = Articles.new(task["url"], task["username"], task["token"])
|
42
|
+
end
|
43
|
+
|
44
|
+
def run
|
45
|
+
@articles.get.each {|article|
|
46
|
+
page_builder.add(article)
|
47
|
+
}
|
48
|
+
|
49
|
+
page_builder.finish
|
50
|
+
|
51
|
+
task_report = {}
|
52
|
+
return task_report
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'embulk/column'
|
2
|
+
|
3
|
+
class Articles
|
4
|
+
def initialize(url, username, token)
|
5
|
+
@url = url
|
6
|
+
@username = username
|
7
|
+
@token = token
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.columns
|
11
|
+
[
|
12
|
+
Embulk::Column.new(0, "id", :long),
|
13
|
+
Embulk::Column.new(1, "url", :string),
|
14
|
+
Embulk::Column.new(2, "html_url", :string),
|
15
|
+
Embulk::Column.new(3, "title", :string),
|
16
|
+
Embulk::Column.new(4, "body", :string),
|
17
|
+
Embulk::Column.new(5, "locale", :string),
|
18
|
+
Embulk::Column.new(6, "source_locale", :string),
|
19
|
+
Embulk::Column.new(7, "author_id", :long),
|
20
|
+
Embulk::Column.new(8, "comments_disabled", :boolean),
|
21
|
+
Embulk::Column.new(9, "outdated_locales", :string),
|
22
|
+
Embulk::Column.new(10, "outdated", :boolean),
|
23
|
+
Embulk::Column.new(11, "label_names", :string),
|
24
|
+
Embulk::Column.new(12, "draft", :boolean),
|
25
|
+
Embulk::Column.new(13, "promoted", :boolean),
|
26
|
+
Embulk::Column.new(14, "position", :long),
|
27
|
+
Embulk::Column.new(15, "vote_sum", :long),
|
28
|
+
Embulk::Column.new(16, "vote_count", :long),
|
29
|
+
Embulk::Column.new(17, "section_id", :long),
|
30
|
+
Embulk::Column.new(18, "user_segment_id", :long),
|
31
|
+
Embulk::Column.new(19, "permission_group_id", :long),
|
32
|
+
Embulk::Column.new(20, "created_at", :timestamp),
|
33
|
+
Embulk::Column.new(21, "edited_at", :timestamp),
|
34
|
+
Embulk::Column.new(22, "updated_at", :timestamp),
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
def get
|
39
|
+
uri = URI.parse("#@url/help_center/ja/articles.json")
|
40
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
41
|
+
http.use_ssl = uri.scheme === "https"
|
42
|
+
|
43
|
+
req = Net::HTTP::Get.new(uri.path)
|
44
|
+
req.basic_auth(@username, @token)
|
45
|
+
response = http.request(req)
|
46
|
+
JSON.parse(response.body)["articles"].map {|article|
|
47
|
+
[
|
48
|
+
article["id"],
|
49
|
+
article["url"],
|
50
|
+
article["html_url"],
|
51
|
+
article["title"],
|
52
|
+
article["body"],
|
53
|
+
article["locale"],
|
54
|
+
article["source_locale"],
|
55
|
+
article["author_id"],
|
56
|
+
article["comments_disabled"],
|
57
|
+
article["outdated_locales"],
|
58
|
+
article["outdated"],
|
59
|
+
article["label_names"],
|
60
|
+
article["draft"],
|
61
|
+
article["promoted"],
|
62
|
+
article["position"],
|
63
|
+
article["vote_sum"],
|
64
|
+
article["vote_count"],
|
65
|
+
article["section_id"],
|
66
|
+
article["user_segment_id"],
|
67
|
+
article["permission_group_id"],
|
68
|
+
Date.parse(article["created_at"]).to_time,
|
69
|
+
Date.parse(article["edited_at"]).to_time,
|
70
|
+
Date.parse(article["updated_at"]).to_time,
|
71
|
+
]
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: embulk-input-zendesk_guide
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yasuhisa Yoshida
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 0.9.23
|
19
|
+
name: embulk
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.23
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.10.6
|
33
|
+
name: bundler
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.10.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '10.0'
|
47
|
+
name: rake
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Loads records from Zendesk Guide.
|
56
|
+
email:
|
57
|
+
- syou6162@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- embulk-input-zendesk_guide.gemspec
|
68
|
+
- lib/embulk/input/zendesk_guide.rb
|
69
|
+
- lib/embulk/input/zendesk_guide/articles.rb
|
70
|
+
homepage: https://github.com/syou6162/embulk-input-zendesk_guide
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.6.14
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Zendesk Guide input plugin for Embulk
|
94
|
+
test_files: []
|