travis-saucelabs-api 0.0.2 → 0.0.3

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: 9a020d8e584148b881c96d7060206d23d527886c
4
- data.tar.gz: e8280c6e4bbdd885ed75f91ba220bd4ea784e605
3
+ metadata.gz: 004d0cef2f71d97a858de7a543ef4b44440fbc6d
4
+ data.tar.gz: 74669ed6b8f114d14cd53483989134bc039bc849
5
5
  SHA512:
6
- metadata.gz: ec8900ed99b31da6d0a1d4f9708f74aeaca8b2e8032d86e78a7c2ab5f02c1dd774345a8c7cde179978dce23008a73d78e8177656375f89dafb79128819459182
7
- data.tar.gz: 158a5a18df2bed7ef52197ad75b6b49400537e0ed0c031e82d62a0701080adc4cf072d4509015eec6a7edc2e0e7ad668057dc5eeacc2e548f7480bbe615d3d3b
6
+ metadata.gz: fd22bf29beb91a8e52e0d301d46680adf22ca6eb68cd2d7e3997f9d7a44fab15fe088303745b974c9ea86cbaeedbc5912ea67002b7e08cf3d657133e0a894e07
7
+ data.tar.gz: 07b3e0e3706b4f60297ad8b908e45ea999fa520ed756c6867c459da0f3c6e0c1d61592b1485e727a4fca11ef809d62ff7c42eabaaa7188cc98070cde43f4deba
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ ## v0.0.3
4
+
5
+ - Allow specifying an image when starting a VM with the CLI (using `--image`).
6
+ - Change the default image name to `ichef-travis-osx8-latest`.
7
+ - Raise errors on all 4xx and 5xx errors. They are raised as
8
+ `Travis::SaucelabsAPI::ClientError` and `Travis::SaucelabsAPI::ServerError`,
9
+ respectively, and both inherit from `Travis::SaucelabsAPI::Error`.
10
+
11
+ ## v0.0.2
12
+
13
+ - Add allow_incoming endpoint, which allows for opening incoming ports in the
14
+ firewall (for example to SSH in from outside the LAN).
15
+ - Require API responses to use the application/json Content-Type to be parsed as
16
+ JSON.
17
+
18
+ ## v0.0.1
19
+
20
+ Initial release
data/README.md CHANGED
@@ -18,10 +18,12 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ ### Library
22
+
21
23
  ``` ruby
22
24
  require 'travis-saucelabs-api'
23
25
 
24
- api = Travis::SaucelabsAPI.new('http://user:password@api.example.com:1234')
26
+ api = Travis::SaucelabsAPI::Connection.new('http://user:password@api.example.com:1234')
25
27
 
26
28
  # The available capacity for the cloud
27
29
  #
@@ -58,6 +60,28 @@ api.open_outgoing('38257917-4fac-68fc-11f4-1575d2ec6847@api#vm1')
58
60
  api.save_image('38257917-4fac-68fc-11f4-1575d2ec6847@api#vm1')
59
61
  ```
60
62
 
63
+ ### CLI
64
+
65
+ To use the CLI, you first need to tell it what the API endpoint is:
66
+
67
+ $ export TRAVIS_SAUCE_API_URI="http://user:password@api-endpoint:port"
68
+
69
+ #### Start a new VM
70
+
71
+ $ travis-saucelabs start
72
+
73
+ #### List information about all VMs
74
+
75
+ $ travis-saucelabs list
76
+
77
+ #### Kill a VM
78
+
79
+ $ travis-saucelabs kill <instance-id>
80
+
81
+ #### Kill all VMs belonging to a worker (by PID)
82
+
83
+ $ travis-saucelabs kill_pid <worker-pid>
84
+
61
85
  ## Contributing
62
86
 
63
87
  1. Fork it
@@ -20,8 +20,14 @@ class TravisSaucelabs < Thor
20
20
  desc 'start', 'Starts a new VM instance'
21
21
  option :hostname
22
22
  option :password
23
+ option :image
23
24
  def start
24
- instance_id = api.start_instance(startup_info)['instance_id']
25
+ instance_id = if options[:image]
26
+ api.start_instance(startup_info, options[:image])['instance_id']
27
+ else
28
+ api.start_instance(startup_info)['instance_id']
29
+ end
30
+
25
31
  puts "Started instance with ID #{instance_id}"
26
32
  print "Allowing outgoing connections..."
27
33
  api.allow_outgoing(instance_id)
@@ -4,9 +4,12 @@ require 'faraday_middleware'
4
4
 
5
5
  module Travis
6
6
  class SaucelabsAPI
7
- class NotFoundError < StandardError; end
7
+ class Error < StandardError; end
8
+ class ClientError < Error; end
9
+ class ServerError < Error; end
10
+ class NotFoundError < ClientError; end
8
11
 
9
- DEFAULT_IMAGE = 'ichef-osx8-10.8-travis'
12
+ DEFAULT_IMAGE = 'ichef-travis-osx8-latest'
10
13
 
11
14
  # Public: Initialize a new API client instance
12
15
  #
@@ -71,7 +74,14 @@ module Travis
71
74
  private
72
75
 
73
76
  def handle_response(response)
74
- raise NotFoundError if response.status == 404
77
+ case response.status
78
+ when 404
79
+ fail NotFoundError, response.body
80
+ when 400...500
81
+ fail ClientError, response.body
82
+ when 500...600
83
+ fail ServerError, response.body
84
+ end
75
85
 
76
86
  response.body
77
87
  end
@@ -1,5 +1,5 @@
1
1
  module Travis
2
2
  class SaucelabsAPI
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis-saucelabs-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Hodne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-08 00:00:00.000000000 Z
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.9'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.9'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.14'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.14'
55
55
  description: Ruby client library for the API Travis uses to spin up OS X VMs
@@ -60,9 +60,10 @@ executables:
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
- - .gitignore
64
- - .rspec
65
- - .travis.yml
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - CHANGES.md
66
67
  - Gemfile
67
68
  - LICENSE.txt
68
69
  - README.md
@@ -89,17 +90,17 @@ require_paths:
89
90
  - lib
90
91
  required_ruby_version: !ruby/object:Gem::Requirement
91
92
  requirements:
92
- - - '>='
93
+ - - ">="
93
94
  - !ruby/object:Gem::Version
94
95
  version: '0'
95
96
  required_rubygems_version: !ruby/object:Gem::Requirement
96
97
  requirements:
97
- - - '>='
98
+ - - ">="
98
99
  - !ruby/object:Gem::Version
99
100
  version: '0'
100
101
  requirements: []
101
102
  rubyforge_project:
102
- rubygems_version: 2.0.3
103
+ rubygems_version: 2.2.2
103
104
  signing_key:
104
105
  specification_version: 4
105
106
  summary: Travis/Sauce Labs API client