syncano 4.0.0.alpha → 4.0.0.alpha1

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: 8fa33e829552d449652567e0ccf85426f4b31d9e
4
- data.tar.gz: 877390535ea162188215684f8b7f58adb788b45b
3
+ metadata.gz: f06e086fb01f6bdd1a005c7ab4618d75babee13e
4
+ data.tar.gz: b906104e4fa06db0cb09e3808d3fa924dcb8d5ce
5
5
  SHA512:
6
- metadata.gz: 8d4a6780ef77bda1100d9f09d5b833e9659890ca318442887a55d6aab5b6685cff320a13912376ba35547db826edd6ae82cec55be4b0a593274252941d68b415
7
- data.tar.gz: 7077b7034ae4bf1189367c5582996579313d630330729d1cc800ab4ca5a71c3a5acf9a5558c8da89e51d391e633a9fce587bb7ae4fca9940a5fffa4092ced573
6
+ metadata.gz: 0174413a95cfca8ed8fc4c05409877a0ca76b2f623da5331374a46263e85a50acf38c6b5bb507fa991f2343f58b8ea6f9e0d71e6dbcfbdb9330bfcea4fd450f5
7
+ data.tar.gz: ac1b5fc9689cac452c336462f7ca71d56b83c67da684e2149ba1ae40bca3c1a51e6a450ae12dc02e582023832a6f15813ab3a5e07b8187a72bc46b76602e8969
data/README.md CHANGED
@@ -16,7 +16,7 @@ After installation, you have to set a path for api root for syncano.
16
16
  If you want to use staging, export:
17
17
 
18
18
  ```bash
19
- $ export API_ROOT=https://v4.hydraengine.com
19
+ $ export API_ROOT=https://api.syncano.rocks
20
20
  ```
21
21
 
22
22
  If you're less adventurous, use our production api servers:
@@ -116,10 +116,51 @@ manually using the API, you can create a schedule to run them periodically, you
116
116
  can create a Webhook (and optionally make it public) to run them from the web,
117
117
  you can create a trigger to run one after a class' object is created, updated or
118
118
  deleted. There are three runtimes available: Ruby, Python and Node. This gem is
119
- available in Ruby runtime (just needs to be required).
119
+ available in Ruby runtime (just needs to be required). Let's create a simple
120
+ codebox and run it.
120
121
 
122
+ ```ruby
123
+ clock = instance.codeboxes.create(name: 'clock', source: 'puts Time.now', runtime_name: 'ruby')
124
+ #=> #<Syncano::Resources::CodeBox config: {}, created_at: Thu, 30 Apr 2015 05:50:09 +0000, description: "", id: 1, name: "clock", runtime_name: "ruby", source: "puts Time.now", updated_at: Thu, 30 Apr 2015 05:50:09 +0000>
125
+ clock.run
126
+ #=> {"status"=>"pending", "links"=>{"self"=>"gv1/instances/a523b7e842dea927d8c306ec0a9a7a4ac30191c2cd034b11d/codeboxes/1/traces/1/"}, "executed_at"=>nil, "result"=>"", "duration"=>nil, "id"=>1}
127
+ ```
128
+
129
+ When you schedule a codebox run, it returns the trace. Immediately after the
130
+ call it's status is pending, so you need to check the trace.
131
+
132
+ ```ruby
133
+ clock.traces.first
134
+ => #<Syncano::Resources::CodeBoxTrace duration: 526, executed_at: Thu, 30 Apr 2015 05:25:14 +0000, id: 1, result: "2015-04-30 05:25:14 +0000", status: "success">
135
+ ```
136
+
137
+ The run method is asynchronous and returns immediately. You should use this to
138
+ run codeboxes when you don't care about results at this very moment. If you
139
+ want to run the codebox and get results in one call, you should use webhooks.
140
+
141
+ # Webhooks
142
+
143
+ You can use webhooks to run codeboxes synchronously. Webhooks can be either
144
+ public or private. You have to provide your API key when calling private ones,
145
+ public are public, you can call them with curl, connect with third party
146
+ services, etc. Ruby:
121
147
 
122
148
 
149
+ ```ruby
150
+ webhook = @instance.webhooks.create slug: 'clock-webhook', codebox: clock.primary_key, public: true
151
+ #=> #<Syncano::Resources::Webhook codebox: 1, public: true, public_link: "a20b0ae122b53b2f2c445f6a7a202b274c3631ad", slug: "clock-webhook">
152
+
153
+ webhook.run['result']
154
+ #=> "2015-04-30 05:51:45 +0000"
155
+ ```
156
+
157
+ and curl
158
+
159
+ ```bash
160
+ $ curl "https://api.syncano.rocks/v1/instances//af248d3e8b92e6e7aaa42dfc41de80c66c90d620cbe3fcd19/webhooks/p/a20b0ae122b53b2f2c445f6a7a202b274c3631ad/"
161
+ {"status": "success", "duration": 270, "result": "2015-04-30 06:11:08 +0000", "executed_at": "2015-04-30T06:11:08.607389Z"}
162
+ ```
163
+
123
164
  ## Contributing
124
165
 
125
166
  1. Fork it
@@ -31,6 +31,10 @@ module Syncano
31
31
  resource_class.create(connection, scope_parameters, attributes)
32
32
  end
33
33
 
34
+ def destroy(primary_key)
35
+ resource_class.destroy connection, scope_parameters, primary_key
36
+ end
37
+
34
38
  def space(at, options = {})
35
39
  Syncano::Resources::Space.new(at, self, options)
36
40
  end
@@ -37,6 +37,12 @@ module Syncano
37
37
  new(connection, scope_parameters, attributes).save
38
38
  end
39
39
 
40
+ def destroy(connection, scope_parameters, pk)
41
+ check_resource_method_existance! :destroy
42
+
43
+ connection.request :delete, member_path(pk, scope_parameters)
44
+ end
45
+
40
46
  def map_attributes_values(attributes)
41
47
  attributes.each do |name, value|
42
48
  attributes[name] = value.to_json if value.is_a?(Array) || value.is_a?(Hash)
@@ -1,3 +1,3 @@
1
1
  module Syncano
2
- VERSION = '4.0.0.alpha'
2
+ VERSION = '4.0.0.alpha1'
3
3
  end
@@ -78,7 +78,10 @@ describe Syncano do
78
78
  expect(object.ballance).to eq(54)
79
79
  expect(object.currency).to eq('GBP')
80
80
 
81
- expect { object.destroy }.to destroy_resource
81
+ expect { subject.destroy(object.primary_key) }.to destroy_resource
82
+ expect {
83
+ subject.destroy(object.primary_key)
84
+ }.to raise_error(Syncano::ClientError, /not found/i)
82
85
  end
83
86
 
84
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syncano
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.alpha
4
+ version: 4.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Zadrożny
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-28 00:00:00.000000000 Z
12
+ date: 2015-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler