mozenda 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df5e788b9aa9cdd973c584fa647f7bb582a5407e
4
- data.tar.gz: 1c568fb8b970edf536f9f09baa0ba8799515c6d5
3
+ metadata.gz: 7f39bbe0114d3b3d16c066170bba5124c557edd2
4
+ data.tar.gz: 1a8499ba06d039538c98af718226c496f2d0c374
5
5
  SHA512:
6
- metadata.gz: 4300329d58e69be4fe6e0b76689f312f4fae8206b737cc457bebb349f57b455b9d5bf1ab23d330433f8c2fe5de14d1d59f1644b01458081b2886ce864a5a7368
7
- data.tar.gz: 2344923a865c406118416d9371b30b01c51a720d43fc3cd597027e284f30a1833d4eb455508dec1b537f987ec9d093b029945ccd4a18df235cd5c09202c66c5d
6
+ metadata.gz: 5fdba3960cc916bd56227b01d426ed4fa7df6f62f87b453065039f19f2d56074efcaa67f19eba1b64e6d5b0ece7a2b6e8aa629e7a00fe61aa1fa49ff6de9ef04
7
+ data.tar.gz: 6e84a481900419d23fc4f301e6dbe22d4a66dd4e8c45bba42cf80a068c8453462d6b31db39d45a7369d320fe2e6e8a448baf8ece9c760e29e5d9d217d89cb93e
data/README.md CHANGED
@@ -50,7 +50,7 @@ collection = Mozenda::Model::Collection.new(collection_id)
50
50
  collection.clear
51
51
  ```
52
52
 
53
- To run Agent:
53
+ To simple run Agent:
54
54
  ```ruby
55
55
  agent_id = 1050
56
56
  agent = Mozenda::Model::Agent.new(agent_id)
@@ -71,17 +71,70 @@ To run Agent with Job.StatusUrl:
71
71
  ```ruby
72
72
  agent_id = 1050
73
73
  agent = Mozenda::Model::Agent.new(agent_id)
74
- optional_params = {}
74
+ optional_params = {:foo => 123, :bar => "xyz"}
75
75
  agent.run(optional_params, {
76
76
  :status_url => "http://localhost:3000/some/path",
77
- :replacement_values => {
78
- :job_id => Mozenda::ReplacementValues::JOB_ID,
79
- :job_status => Mozenda::ReplacementValues::JOB_STATUS,
80
- :job_ended => Mozenda::ReplacementValues::JOB_ENDED
81
- }
77
+ :replacement_values => [:job_id, :job_status, :job_ended]
82
78
  })
83
79
  ```
84
80
 
81
+ To get Agent info:
82
+ ```ruby
83
+ agent_id = 1050
84
+ agent = Mozenda::Model::Agent.new(agent_id)
85
+ agent_get_response = agent.get
86
+ agent_get_response.to_h
87
+ agent_get_response.to_xml
88
+ ```
89
+
90
+ To get Agent Jobs list info:
91
+ ```ruby
92
+ agent_id = 1050
93
+ agent = Mozenda::Model::Agent.new(agent_id)
94
+ agent_get_jobs_response = agent.get_jobs
95
+ agent_get_jobs_response.to_h
96
+ agent_get_jobs_response.to_xml
97
+ agent_get_jobs_response.jobs_list
98
+ ```
99
+
100
+ To simple publish Collection:
101
+ ```ruby
102
+ collection_id = 1055
103
+ collection = Mozenda::Model::Collection.new(collection_id)
104
+ collection_publish_response = collection.publish
105
+ collection_publish_response.to_h
106
+ collection_publish_response.to_xml
107
+ ```
108
+
109
+ To publish Collection with some status URL & replacement values:
110
+ ```ruby
111
+ collection_id = 1055
112
+ collection = Mozenda::Model::Collection.new(collection_id)
113
+ params = {
114
+ :status_url => "http://my-app.com/-mozen-on-publish-url?my_param=123&other_param=foo",
115
+ :replacement_values => [:job_id, :job_status, :job_created, :job_ended]
116
+ }
117
+ collection_publish_response = collection.publish(params)
118
+ collection_publish_response.to_h
119
+ collection_publish_response.to_xml
120
+ ```
121
+
122
+ Replacement values (defined in Mozenda::REPLACEMENT_VALUES) for Collection.Publish and/or Agent.Run:
123
+ ```ruby
124
+ Mozenda::REPLACEMENT_VALUES = {
125
+ agent_id: "AgentID",
126
+ agent_name: "Agent.Name",
127
+ agent_description: "Agent.Description",
128
+ agent_domain: "Agent.Domain",
129
+ job_id: "JobID",
130
+ job_status: "Job.Status",
131
+ job_created: "Job.Created",
132
+ job_ended: "Job.Ended",
133
+ job_name: "Job.Name",
134
+ job_description: "Job.Description"
135
+ }
136
+ ```
137
+
85
138
  To generate XML file for bulk Collection.AddItem:
86
139
  ```ruby
87
140
  data = [
@@ -130,6 +183,14 @@ job_get_response.state # => "Done"
130
183
  job_get_response.error? # => false
131
184
  ```
132
185
 
186
+ To pause running Job:
187
+ ```ruby
188
+ job_id = "E656D634-C63F-46D9-AFB5-C9AE1F1F2A9E"
189
+ job_pause_response = Mozenda::Model::Job.pause(job_id)
190
+ job_pause_response.to_xml
191
+ job_resume_response.to_h
192
+ ```
193
+
133
194
  To resume Job that is in a Paused or Error state:
134
195
  ```ruby
135
196
  job_id = "7E08EB1F-DDA6-4459-BBDA-3F88B4AB7B7C"
@@ -138,6 +199,14 @@ job_resume_response.to_xml
138
199
  job_resume_response.to_h
139
200
  ```
140
201
 
202
+ To cancel Job that is in a Paused or Error state:
203
+ ```ruby
204
+ job_id = "7E08EB1F-DDA6-4459-BBDA-3F88B4AB7B7C"
205
+ job_cancel_response = Mozenda::Model::Job.cancel(job_id)
206
+ job_resume_response.to_xml
207
+ job_resume_response.to_h
208
+ ```
209
+
141
210
 
142
211
  ## TODO
143
212
  * Implement requests-per-minute limit.
@@ -19,5 +19,10 @@ module Mozenda::Model
19
19
  request.send!
20
20
  end
21
21
 
22
+ def get_jobs
23
+ request = Mozenda::Request::AgentGetJobs.new(:agent_id => @id)
24
+ request.send!
25
+ end
26
+
22
27
  end
23
28
  end
@@ -5,6 +5,7 @@ end
5
5
 
6
6
  require 'mozenda/request/base'
7
7
  require 'mozenda/request/agent_get'
8
+ require 'mozenda/request/agent_get_jobs'
8
9
  require 'mozenda/request/agent_run'
9
10
  require 'mozenda/request/collection_add_item'
10
11
  require 'mozenda/request/collection_add_item_bulk'
@@ -0,0 +1,15 @@
1
+ module Mozenda::Request
2
+ class AgentGetJobs < Mozenda::Request::Base
3
+
4
+ def initialize options
5
+ super
6
+ put_additional_param("AgentID", options[:agent_id])
7
+ end
8
+
9
+ private
10
+
11
+ OPERATION = "Agent.GetJobs"
12
+ REQUIRED_PARAMS = ["AgentID", "Operation"].freeze
13
+
14
+ end
15
+ end
@@ -5,6 +5,7 @@ end
5
5
 
6
6
  require 'mozenda/response/base'
7
7
  require 'mozenda/response/agent_get'
8
+ require 'mozenda/response/agent_get_jobs'
8
9
  require 'mozenda/response/agent_run'
9
10
  require 'mozenda/response/collection_add_item'
10
11
  require 'mozenda/response/collection_clear'
@@ -0,0 +1,13 @@
1
+ module Mozenda::Response
2
+ class AgentGetJobs < Mozenda::Response::Base
3
+
4
+ def job_list
5
+ body_hash["JobList"]["Job"]
6
+ end
7
+
8
+ private
9
+
10
+ NAME = "AgentGetJobsResponse"
11
+
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Mozenda
2
2
 
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mozenda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Woloszun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-28 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,6 +119,7 @@ files:
119
119
  - lib/mozenda/model/job.rb
120
120
  - lib/mozenda/request.rb
121
121
  - lib/mozenda/request/agent_get.rb
122
+ - lib/mozenda/request/agent_get_jobs.rb
122
123
  - lib/mozenda/request/agent_run.rb
123
124
  - lib/mozenda/request/base.rb
124
125
  - lib/mozenda/request/collection_add_item.rb
@@ -131,6 +132,7 @@ files:
131
132
  - lib/mozenda/request/job_resume.rb
132
133
  - lib/mozenda/response.rb
133
134
  - lib/mozenda/response/agent_get.rb
135
+ - lib/mozenda/response/agent_get_jobs.rb
134
136
  - lib/mozenda/response/agent_run.rb
135
137
  - lib/mozenda/response/base.rb
136
138
  - lib/mozenda/response/collection_add_item.rb