docomo-nlu 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -1
  3. data/docomo-nlu.gemspec +1 -0
  4. data/lib/docomo-nlu/management/{account.rb → V23/account.rb} +4 -6
  5. data/lib/docomo-nlu/management/{aiml_base.rb → V23/aiml_base.rb} +31 -5
  6. data/lib/docomo-nlu/management/{base.rb → V23/base.rb} +5 -4
  7. data/lib/docomo-nlu/management/{bot.rb → V23/bot.rb} +2 -2
  8. data/lib/docomo-nlu/management/{config.rb → V23/config.rb} +2 -2
  9. data/lib/docomo-nlu/management/{default_predicate.rb → V23/default_predicate.rb} +2 -2
  10. data/lib/docomo-nlu/management/{map.rb → V23/map.rb} +2 -2
  11. data/lib/docomo-nlu/management/{multipart_base.rb → V23/multipart_base.rb} +1 -1
  12. data/lib/docomo-nlu/management/{ng_word.rb → V23/ng_word.rb} +2 -2
  13. data/lib/docomo-nlu/management/{ok_word.rb → V23/ok_word.rb} +2 -2
  14. data/lib/docomo-nlu/management/{organization.rb → V23/organization.rb} +2 -2
  15. data/lib/docomo-nlu/management/{organization_member.rb → V23/organization_member.rb} +2 -2
  16. data/lib/docomo-nlu/management/{predicate_name.rb → V23/predicate_name.rb} +2 -2
  17. data/lib/docomo-nlu/management/{project.rb → V23/project.rb} +2 -2
  18. data/lib/docomo-nlu/management/{project_member.rb → V23/project_member.rb} +2 -2
  19. data/lib/docomo-nlu/management/{property.rb → V23/property.rb} +2 -2
  20. data/lib/docomo-nlu/management/{provider.rb → V23/provider.rb} +2 -2
  21. data/lib/docomo-nlu/management/{scenario.rb → V23/scenario.rb} +5 -5
  22. data/lib/docomo-nlu/management/{scenario_project.rb → V23/scenario_project.rb} +2 -2
  23. data/lib/docomo-nlu/management/{scenario_util.rb → V23/scenario_util.rb} +2 -2
  24. data/lib/docomo-nlu/management/{set.rb → V23/set.rb} +2 -2
  25. data/lib/docomo-nlu/management/{task_project.rb → V23/task_project.rb} +2 -2
  26. data/lib/docomo-nlu/management/V26/account.rb +31 -0
  27. data/lib/docomo-nlu/management/V26/aiml_base.rb +199 -0
  28. data/lib/docomo-nlu/management/V26/base.rb +88 -0
  29. data/lib/docomo-nlu/management/V26/bot.rb +18 -0
  30. data/lib/docomo-nlu/management/V26/config.rb +25 -0
  31. data/lib/docomo-nlu/management/V26/default_predicate.rb +15 -0
  32. data/lib/docomo-nlu/management/V26/map.rb +10 -0
  33. data/lib/docomo-nlu/management/V26/multipart_base.rb +83 -0
  34. data/lib/docomo-nlu/management/V26/ng_word.rb +10 -0
  35. data/lib/docomo-nlu/management/V26/ok_word.rb +10 -0
  36. data/lib/docomo-nlu/management/V26/organization.rb +23 -0
  37. data/lib/docomo-nlu/management/V26/organization_member.rb +15 -0
  38. data/lib/docomo-nlu/management/V26/predicate_name.rb +15 -0
  39. data/lib/docomo-nlu/management/V26/project.rb +16 -0
  40. data/lib/docomo-nlu/management/V26/project_member.rb +15 -0
  41. data/lib/docomo-nlu/management/V26/property.rb +10 -0
  42. data/lib/docomo-nlu/management/V26/provider.rb +17 -0
  43. data/lib/docomo-nlu/management/V26/scenario.rb +29 -0
  44. data/lib/docomo-nlu/management/V26/scenario_project.rb +10 -0
  45. data/lib/docomo-nlu/management/V26/scenario_util.rb +30 -0
  46. data/lib/docomo-nlu/management/V26/set.rb +10 -0
  47. data/lib/docomo-nlu/management/V26/task_project.rb +20 -0
  48. data/lib/docomo-nlu/management.rb +48 -22
  49. data/lib/docomo-nlu/version.rb +1 -1
  50. metadata +59 -23
@@ -0,0 +1,199 @@
1
+ # frozen_string_literal: true
2
+
3
+ # download([:aiml,:dat,:archive],scenarioId)
4
+ # GET /{projectId}/bots/{botId}/aiml/{scenarioId}
5
+ # GET /{projectId}/bots/{botId}/dat
6
+ # GET /{projectId}/bots/{botId}/archive
7
+
8
+ # upload([:aiml,:dat,:archive],filepath)
9
+ # /{projectId}/bots/{botId}/aiml
10
+ # /{projectId}/bots/{botId}/dat
11
+ # /{projectId}/bots/{botId}/archive
12
+
13
+ # Not supported
14
+ # GET /{projectId}/bots/{botId}/archive/aiml
15
+
16
+ # require 'rubyzip'
17
+
18
+ require "tempfile"
19
+ module DocomoNlu
20
+ module Management::V26
21
+ class AIMLBase < Base
22
+ ## For AIML
23
+
24
+ def download(extra_path = "")
25
+ prefix_options[:bot_id] ||= botId
26
+ @attributes[:file] = self.class.download(prefix_options, extra_path).file
27
+ end
28
+
29
+ def upload(file, type = :aiml)
30
+ prefix_options[:bot_id] ||= botId
31
+ prefix_options[:method] ||= type
32
+ self.class.upload(file, prefix_options)
33
+ end
34
+
35
+ def compile
36
+ prefix_options[:bot_id] ||= botId
37
+ self.class.compile(prefix_options)
38
+ end
39
+
40
+ def transfer
41
+ prefix_options[:bot_id] ||= botId
42
+ self.class.deploy_request(prefix_options)
43
+ end
44
+
45
+ def deploy
46
+ prefix_options[:bot_id] ||= botId
47
+ self.class.deploy(prefix_options)
48
+ end
49
+
50
+ ## For FAQ
51
+
52
+ def upload_userdic(file)
53
+ prefix_options[:bot_id] ||= botId
54
+ prefix_options[:method] = "userDic"
55
+ self.class.upload(file, prefix_options)
56
+ end
57
+
58
+ def upload_stopkey(file)
59
+ prefix_options[:bot_id] ||= botId
60
+ prefix_options[:method] = "stopkey"
61
+ self.class.upload(file, prefix_options)
62
+ end
63
+
64
+ def download_stopkey
65
+ prefix_options[:bot_id] ||= botId
66
+ prefix_options[:method] = "stopkey"
67
+ @attributes[:stopkey] = self.class.download(prefix_options).file
68
+ end
69
+
70
+ def upload_truthlist(file)
71
+ prefix_options[:bot_id] ||= botId
72
+ prefix_options[:method] = "truthlist"
73
+ self.class.upload(file, prefix_options)
74
+ end
75
+
76
+ def download_truthlist
77
+ prefix_options[:bot_id] ||= botId
78
+ prefix_options[:method] = "truthlist"
79
+ @attributes[:truthlist] = self.class.download(prefix_options).file
80
+ end
81
+
82
+ def upload_entry(file)
83
+ prefix_options[:bot_id] ||= botId
84
+ prefix_options[:method] = "entry"
85
+ self.class.upload(file, prefix_options)
86
+ end
87
+
88
+ def check_faq_status(method)
89
+ prefix_options[:bot_id] ||= botId
90
+ prefix_options[:method] = method
91
+ self.class.check_status(:faq, "#{FileModel.collection_path(prefix_options)}/status")
92
+ end
93
+
94
+ class << self
95
+ def download(prefix_options, extra_path = "")
96
+ conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
97
+ builder.adapter :net_http
98
+ end
99
+ conn.headers["Authorization"] = access_token
100
+ response = conn.get("#{FileModel.collection_path(prefix_options)}/#{extra_path}")
101
+
102
+ if check_response(response)
103
+ instantiate_record({}, prefix_options).tap do |record|
104
+ record.file = Tempfile.open(["docomo-nlu", ".#{prefix_options[:method]}"]) do |f|
105
+ f.write response.body.force_encoding("UTF-8")
106
+ f
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ def upload(file, prefix_options)
113
+ conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
114
+ builder.request :multipart # マルチパートでデータを送信
115
+ builder.request :url_encoded
116
+ builder.adapter :net_http
117
+ end
118
+ conn.headers["Authorization"] = access_token
119
+ params = {
120
+ uploadFile: Faraday::UploadIO.new(file.path, "text/plain"),
121
+ }
122
+ response = conn.put FileModel.collection_path(prefix_options), params
123
+ check_response(response)
124
+ end
125
+
126
+ def compile(prefix_options)
127
+ return if deploy_request(:compile, prefix_options) != ""
128
+ end
129
+
130
+ def transfer(prefix_options)
131
+ return if deploy_request(:transfer, prefix_options) != ""
132
+ end
133
+
134
+ def deploy_request(method, prefix_options)
135
+ response_body = JSON.parse(connection.post(Scenario.element_path(method, prefix_options), "", headers).body)
136
+ # Sometimes, API returns wrong url, replace correct path.
137
+ URI.parse(response_body["statusUri"]).path.gsub!(/NLPManagementAPI/, "management/v2.6")
138
+ end
139
+
140
+ def deploy(prefix_options)
141
+ # compile and status check
142
+ compile_status = false
143
+ check_path = deploy_request(:compile, prefix_options)
144
+ while check_path && compile_status != "Completed"
145
+ sleep(0.2)
146
+ compile_status = check_status(:compile, check_path)
147
+ raise ActiveResource::ServerError if %w[ErrorFinish NotCompiled].include?(compile_status)
148
+ end
149
+
150
+ # transfer and status check
151
+ transfer_status = false
152
+ check_path = deploy_request(:transfer, prefix_options)
153
+ while check_path && transfer_status != "Completed"
154
+ sleep(0.2)
155
+ transfer_status = check_status(:transfer, check_path)
156
+ raise ActiveResource::ServerError if %w[ErrorFinish NotTransfered].include?(transfer_status)
157
+ end
158
+ true
159
+ end
160
+
161
+ def check_status(method, path)
162
+ case method
163
+ when :compile, :faq then JSON.parse(connection.get(path, headers).body)["status"]
164
+ when :transfer then JSON.parse(connection.get(path, headers).body)["transferStatusResponses"][0]["status"]
165
+ end
166
+ end
167
+
168
+ # def generate_file(response, method)
169
+ # case method
170
+ # when :aiml, :dat then
171
+ # Tempfile.open(["docomo-nlu", ".#{prefix_options[:method].to_s}"]) do |f|
172
+ # f.write response.body.force_encoding("UTF-8")
173
+ # f
174
+ # end
175
+ # when :zip then
176
+ # zip_file = Tempfile.new(["docomo-nlu", ".#{prefix_options[:method].to_s.gsub(/archive/, "zip")}"])
177
+ # Zip::OutputStream.open(zip_file.path) do |zip|
178
+ # @targets.each do |target|
179
+ # zip.put_next_entry("#{target.filename}.pdf")
180
+ # zip.print Net::HTTP.get URI.parse(target.url)
181
+ # end
182
+ # end
183
+ # Zip::File.open_buffer(file.read) do |zf|
184
+ # zf.each do |entry|
185
+ # p entry.name # ファイル名
186
+ # p entry.get_input_stream.read # ファイルの中身
187
+ # end
188
+ # end
189
+ # end
190
+ # end
191
+ end
192
+
193
+ class FileModel < Base
194
+ self.element_name = ""
195
+ self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/:method"
196
+ end
197
+ end
198
+ end
199
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+
5
+ module DocomoNlu
6
+ module Management::V26
7
+ class Base < ActiveResource::Base
8
+ ## For Dynamically generated headers via http://rmosolgo.github.io/blog/2014/02/05/dynamically-generated-headers-for-activeresource-requests/
9
+ cattr_accessor :static_headers
10
+ cattr_accessor :access_token
11
+
12
+ ## Dynamic headers
13
+ self.static_headers = headers
14
+
15
+ ## Admin Accesstoken
16
+ self.access_token = DocomoNlu.config.admin_access_token
17
+
18
+ ## Setting Endpoint.
19
+ self.site = DocomoNlu.config.nlu_host
20
+
21
+ ## Remove format in path (remove .json)
22
+ self.include_format_in_path = false
23
+
24
+ self.format = :json
25
+
26
+ ## Get NLPManagement's AccessToken.
27
+ def login(accountName, password)
28
+ request_body = { accountName: accountName, password: password }.to_json
29
+ response_body = JSON.parse(connection.post("/management/v2.6/login", request_body, self.class.headers).body)
30
+ self.access_token = response_body["accessToken"]
31
+ end
32
+
33
+ ## Delete NLPManagement's AccessToken.
34
+ def logout
35
+ res = connection.get("/management/v2.6/logout", self.class.headers) if access_token.present?
36
+ raise ActiveResource::BadRequest, "Invalid access token" unless res
37
+
38
+ self.access_token = nil
39
+ true
40
+ end
41
+
42
+ ## Override. Insert generated id to parameter 'id' after save or create
43
+ def id_from_response(response)
44
+ ActiveSupport::JSON.decode(response.body)["#{self.class.to_s.split("::").last.downcase!}Id"] if response.body.present?
45
+ end
46
+
47
+ class << self
48
+ def instantiate_collection(collection, original_params = {}, prefix_options = {})
49
+ if collection.is_a?(Hash)
50
+ collection = if collection.empty? || collection.first[1].nil?
51
+ []
52
+ else
53
+ [collection]
54
+ end
55
+ elsif collection[0].is_a?(String)
56
+ collection = [{ params: collection }]
57
+ end
58
+ super
59
+ end
60
+
61
+ def instantiate_record(record, prefix_options = {})
62
+ record = record[0] if record.is_a?(Array)
63
+ resource_id = record["#{to_s.split("::").last.downcase!}Id"]
64
+ record["id"] = resource_id if resource_id
65
+ super
66
+ end
67
+
68
+ def headers
69
+ new_headers = static_headers.clone
70
+ new_headers["Authorization"] = access_token
71
+ new_headers
72
+ end
73
+
74
+ def check_response(response)
75
+ case response.status
76
+ when 400 then raise ActiveResource::BadRequest, response
77
+ when 401 then raise ActiveResource::UnauthorizedAccess, response
78
+ when 403 then raise ActiveResource::ForbiddenAccess, response
79
+ when 404 then raise ActiveResource::ResourceNotFound, response
80
+ when 409 then raise ActiveResource::ResourceConflict, response
81
+ when 503 then raise ActiveResource::ServerError, response
82
+ when 200..204 then true
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class Bot < AIMLBase
6
+ self.element_name = "bots"
7
+ self.prefix = "/management/v2.6/projects/:project_id/"
8
+
9
+ # Parameter for create
10
+ # {
11
+ # "botId": "botid",
12
+ # "scenarioProjectId", "DSU",
13
+ # "language": "ja-JP",
14
+ # "description": "hello"
15
+ # }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class Config < Base
6
+ self.element_name = "configs"
7
+ self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/"
8
+
9
+ # {
10
+ # "dialogTimeout": 300,
11
+ # "replyTimeout": 300,
12
+ # "xxxxUrl": "http://xxx",
13
+ # "yyyyUrl": "http://xxx",
14
+ # "sensitiveInfo": "aa.bb, ccc.ddd...",
15
+ # "sraix" : [true|false],
16
+ # "taskServerUrl": "http://xxx"
17
+ # }
18
+
19
+ def destroy(keys)
20
+ self.id = keys.join(",")
21
+ super()
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class DefaultPredicate < Base
6
+ self.element_name = "defaultPredicates"
7
+ self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/"
8
+
9
+ def destroy(keys)
10
+ self.id = keys.join(",")
11
+ super()
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class Map < MultipartBase
6
+ self.element_name = "maps"
7
+ self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tempfile"
4
+ module DocomoNlu
5
+ module Management::V26
6
+ class MultipartBase < Base
7
+ def save
8
+ self.class.create(attributes[:file], prefix_options)
9
+ end
10
+
11
+ def destroy
12
+ self.id = try(:category)
13
+ super
14
+ end
15
+
16
+ class << self
17
+ def create(file, prefix_options)
18
+ check_prefix_options(prefix_options)
19
+ raise ActiveResource::BadRequest, "" unless file.instance_of?(File)
20
+
21
+ upload(file, prefix_options)
22
+ end
23
+
24
+ def find(*arguments)
25
+ scope = arguments.slice!(0)
26
+ options = arguments.slice!(0) || {}
27
+
28
+ prefix_options, = split_options(options[:params])
29
+ check_prefix_options(prefix_options)
30
+
31
+ case scope
32
+ when :all then download(nil, prefix_options)
33
+ else download(scope, prefix_options)
34
+ end
35
+ end
36
+
37
+ def where(clauses = {})
38
+ raise ArgumentError, "expected a clauses Hash, got #{clauses.inspect}" unless clauses.is_a? Hash
39
+
40
+ category = clauses[:category]
41
+ find(category, params: clauses)
42
+ end
43
+
44
+ private
45
+
46
+ def download(category = nil, prefix_options)
47
+ extention = category.blank? ? ".zip" : ".map"
48
+
49
+ conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
50
+ builder.adapter :net_http
51
+ end
52
+ conn.headers["Authorization"] = access_token
53
+
54
+ response = conn.get(element_path(category, prefix_options))
55
+
56
+ if check_response(response)
57
+ instantiate_record({}, prefix_options).tap do |record|
58
+ record.file = Tempfile.open(["docomo-nlu", extention]) do |f|
59
+ f.write response.body.force_encoding("UTF-8")
60
+ f
61
+ end
62
+ record.category = category
63
+ end
64
+ end
65
+ end
66
+
67
+ def upload(file, prefix_options)
68
+ conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
69
+ builder.request :multipart # マルチパートでデータを送信
70
+ builder.request :url_encoded
71
+ builder.adapter :net_http
72
+ end
73
+ conn.headers["Authorization"] = access_token
74
+ params = {
75
+ uploadFile: Faraday::UploadIO.new(file.path, "text/plain"),
76
+ }
77
+ response = conn.put collection_path(prefix_options), params
78
+ check_response(response)
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class NGWord < Base
6
+ self.element_name = "ngWords"
7
+ self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class OKWord < Base
6
+ self.element_name = "okWords"
7
+ self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class Organization < Base
6
+ self.element_name = "organizations"
7
+ self.prefix = "/management/v2.6/"
8
+
9
+ # Parameter create
10
+ # {
11
+ # "organizationName": "your organization name",
12
+ # "address": "address",
13
+ # "tel": "tel"
14
+ # }
15
+
16
+ def to_json(options = {})
17
+ attributes.delete("organizationId")
18
+ attributes.delete("id")
19
+ super
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class OrganizationMember < Base
6
+ self.element_name = "members"
7
+ self.prefix = "/management/v2.6/organizations/:organization_id/"
8
+
9
+ def destroy
10
+ self.id = accountId
11
+ super
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class PredicateName < Base
6
+ self.element_name = "predicateNames"
7
+ self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/"
8
+
9
+ def destroy(keys)
10
+ self.id = keys.join(",")
11
+ super()
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class Project < Base
6
+ self.element_name = "projects"
7
+ self.prefix = "/management/v2.6/"
8
+
9
+ # Parameter for create
10
+ # {
11
+ # "projectName": "your project name"
12
+ # "organizationId": "your organization id"
13
+ # }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class ProjectMember < Base
6
+ self.element_name = "members"
7
+ self.prefix = "/management/v2.6/projects/:project_id/"
8
+
9
+ def destroy
10
+ self.id = accountId
11
+ super
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class Property < Base
6
+ self.element_name = "properties"
7
+ self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class Provider < Base
6
+ self.element_name = "providers"
7
+ self.prefix = "/management/v2.6/"
8
+
9
+ # Parameter for create
10
+ # {
11
+ # "organizationId": "id",
12
+ # "serverKind":"SS",
13
+ # "serverId": "DSU"
14
+ # }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class Scenario < AIMLBase
6
+ self.element_name = "scenarios"
7
+ self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/"
8
+
9
+ @permitted_root_param = [:userScenarios, :templateScenarios]
10
+ @permitted_userScenarios_param = [:scenarioId, :description, :compileFlag]
11
+
12
+ def save
13
+ @attributes.select! {|a| a =~ /(userScenarios|templateScenarios)/ }
14
+ userScenarios.each do |us|
15
+ us.attributes.select! {|a| a =~ /(scenarioId|description|compileFlag)/ }
16
+ end
17
+ super
18
+ end
19
+
20
+ def destroy(scenario_id)
21
+ self.id = scenario_id
22
+ super()
23
+ end
24
+
25
+ class UserScenarios < Base; end
26
+ class TemplateScenarios < Base; end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class ScenarioProject < Base
6
+ self.element_name = "scenarioProjects"
7
+ self.prefix = "/management/v2.6/"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class ScenarioUtil < Base
6
+ self.element_name = "scenarioUtils"
7
+ self.prefix = "/management/v2.6/"
8
+
9
+ def normalize
10
+ # TODO
11
+ end
12
+
13
+ def matches
14
+ # TODO
15
+ end
16
+
17
+ def save
18
+ print "Method not used"
19
+ end
20
+
21
+ def destroy
22
+ print "Method not used"
23
+ end
24
+
25
+ def delete
26
+ print "Method not used"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DocomoNlu
4
+ module Management::V26
5
+ class Set < MultipartBase
6
+ self.element_name = "sets"
7
+ self.prefix = "/management/v2.6/projects/:project_id/bots/:bot_id/"
8
+ end
9
+ end
10
+ end