vsphere-automation-runtime 0.4.3 → 0.4.7

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +20 -0
  3. data/lib/vsphere-automation-runtime/api_client.rb +5 -3
  4. data/lib/vsphere-automation-runtime/configuration.rb +7 -3
  5. data/lib/vsphere-automation-runtime/version.rb +1 -1
  6. metadata +8 -49
  7. data/Gemfile +0 -12
  8. data/Gemfile.lock +0 -71
  9. data/README.md +0 -44
  10. data/Rakefile +0 -18
  11. data/coverage/.last_run.json +0 -5
  12. data/coverage/.resultset.json +0 -828
  13. data/coverage/.resultset.json.lock +0 -0
  14. data/coverage/assets/0.10.2/application.css +0 -799
  15. data/coverage/assets/0.10.2/application.js +0 -1707
  16. data/coverage/assets/0.10.2/colorbox/border.png +0 -0
  17. data/coverage/assets/0.10.2/colorbox/controls.png +0 -0
  18. data/coverage/assets/0.10.2/colorbox/loading.gif +0 -0
  19. data/coverage/assets/0.10.2/colorbox/loading_background.png +0 -0
  20. data/coverage/assets/0.10.2/favicon_green.png +0 -0
  21. data/coverage/assets/0.10.2/favicon_red.png +0 -0
  22. data/coverage/assets/0.10.2/favicon_yellow.png +0 -0
  23. data/coverage/assets/0.10.2/loading.gif +0 -0
  24. data/coverage/assets/0.10.2/magnify.png +0 -0
  25. data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  26. data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  27. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  28. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  29. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  30. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  31. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  32. data/coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  33. data/coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png +0 -0
  34. data/coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  35. data/coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png +0 -0
  36. data/coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png +0 -0
  37. data/coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  38. data/coverage/index.html +0 -5100
  39. data/git_push.sh +0 -55
  40. data/pkg/vsphere-automation-runtime-0.4.1.gem +0 -0
  41. data/pkg/vsphere-automation-runtime-0.4.2.gem +0 -0
  42. data/spec/api_client_spec.rb +0 -249
  43. data/spec/configuration_spec.rb +0 -38
  44. data/spec/spec_helper.rb +0 -110
  45. data/vsphere-automation-runtime.gemspec +0 -38
@@ -1,55 +0,0 @@
1
- #!/bin/sh
2
- #
3
- # Generated by: https://openapi-generator.tech
4
- #
5
- # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
6
- #
7
- # Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
8
-
9
- git_user_id=$1
10
- git_repo_id=$2
11
- release_note=$3
12
-
13
- if [ "$git_user_id" = "" ]; then
14
- git_user_id="GIT_USER_ID"
15
- echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
16
- fi
17
-
18
- if [ "$git_repo_id" = "" ]; then
19
- git_repo_id="GIT_REPO_ID"
20
- echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
21
- fi
22
-
23
- if [ "$release_note" = "" ]; then
24
- release_note="Minor update"
25
- echo "[INFO] No command line input provided. Set \$release_note to $release_note"
26
- fi
27
-
28
- # Initialize the local directory as a Git repository
29
- git init
30
-
31
- # Adds the files in the local repository and stages them for commit.
32
- git add .
33
-
34
- # Commits the tracked changes and prepares them to be pushed to a remote repository.
35
- git commit -m "$release_note"
36
-
37
- # Sets the new remote
38
- git_remote=`git remote`
39
- if [ "$git_remote" = "" ]; then # git remote not defined
40
-
41
- if [ "$GIT_TOKEN" = "" ]; then
42
- echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
43
- git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
44
- else
45
- git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
46
- fi
47
-
48
- fi
49
-
50
- git pull origin master
51
-
52
- # Pushes (Forces) the changes in the local repository up to the remote repository
53
- echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
54
- git push origin master 2>&1 | grep -v 'To https'
55
-
@@ -1,249 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe VSphereAutomation::ApiClient do
4
- describe '.default' do
5
- it 'returns the same instance every time' do
6
- first_instance = VSphereAutomation::ApiClient.default
7
- second_instance = VSphereAutomation::ApiClient.default
8
- third_instance = VSphereAutomation::ApiClient.default
9
- expect(first_instance).to be(second_instance)
10
- expect(first_instance).to be(third_instance)
11
- end
12
- end
13
-
14
- describe '#build_collection_param' do
15
- context 'when called with format :multi' do
16
- it 'returns the collection' do
17
- params = { foo: 'bar', baz: 'quux' }
18
- expect(subject.build_collection_param(params, :multi)).to eq(params)
19
- end
20
- end
21
- end
22
-
23
- describe '#call_api' do
24
- let(:host) { 'example.com' }
25
- let(:config) do
26
- VSphereAutomation::Configuration.new.tap do |c|
27
- c.scheme = 'https'
28
- c.host = host
29
- end
30
- end
31
- let(:url) { 'https://example.com/rest/test' }
32
- subject { VSphereAutomation::ApiClient.new(config) }
33
-
34
- it 'adds headers to request' do
35
- headers = { 'foo' => 'bar' }
36
- stub_request(:get, url).with(headers: headers)
37
-
38
- subject.call_api(:GET, '/test', header_params: headers)
39
-
40
- expect(a_request(:get, url).with(headers: headers)).to have_been_made
41
- end
42
-
43
- it 'adds query parameters to request' do
44
- query_params = { 'foo' => 'bar' }
45
- stub_request(:get, url).with(query: query_params)
46
-
47
- subject.call_api(:GET, '/test', query_params: query_params)
48
-
49
- expect(a_request(:get, url).with(query: query_params)).to have_been_made
50
- end
51
-
52
- it 'keeps query parameters from the path to request' do
53
- # The specs have some paths that contain query parameters already. This
54
- # test is to make sure they don't get overwritten.
55
- key = '~foo'
56
- value = 'bar'
57
- query_params = { key => value }
58
- stub_request(:post, url).with(query: query_params)
59
-
60
- subject.call_api(:POST, "/test?#{key}=#{value}")
61
-
62
- expect(a_request(:post, url).with(query: query_params)).to have_been_made
63
- end
64
-
65
- it 'adds form parameters to the request body' do
66
- form_params = { 'foo' => 'bar' }
67
- body = form_params.to_a.map { |e| e.join('=') }.join('&')
68
- stub_request(:get, url).with(body: body)
69
-
70
- subject.call_api(:GET, '/test', form_params: form_params)
71
-
72
- expect(a_request(:get, url).with(body: body)).to have_been_made
73
- end
74
-
75
- it 'uses basic auth information from configuration' do
76
- auth_name = 'basic_auth'
77
- auth_header = { config.auth_settings[auth_name][:key] =>
78
- config.auth_settings[auth_name][:value] }
79
- stub_request(:get, url).with(headers: auth_header)
80
-
81
- subject.call_api(:GET, '/test', auth_names: [auth_name])
82
-
83
- expect(a_request(:get, url)
84
- .with(headers: auth_header)).to have_been_made
85
- end
86
-
87
- it 'use API key information from configuration' do
88
- auth_name = 'api_key'
89
- config.api_key[config.auth_settings[auth_name][:key]] = 'foo'
90
- auth_header = { config.auth_settings[auth_name][:key] =>
91
- config.auth_settings[auth_name][:value] }
92
- stub_request(:get, url).with(headers: auth_header)
93
-
94
- subject.call_api(:GET, '/test', auth_names: [auth_name])
95
-
96
- expect(a_request(:get, url)
97
- .with(headers: auth_header)).to have_been_made
98
- end
99
-
100
- it 'updates api_key from responses with set-cookie header' do
101
- key = config.auth_settings['api_key'][:key]
102
- value = 'foo'
103
- cookie = "#{key}=#{value};Path=/rest;Secure;HttpOnly"
104
- set_cookie_header = { 'set-cookie' => cookie }
105
- auth_header = { key => value }
106
- stub_request(:get, url + '1').to_return(headers: set_cookie_header)
107
- stub_request(:get, url + '2').with(headers: auth_header)
108
-
109
- subject.call_api(:GET, '/test1')
110
- subject.call_api(:GET, '/test2', auth_names: ['api_key'])
111
-
112
- expect(a_request(:get, url + '1')).to have_been_made
113
- expect(a_request(:get, url + '2')
114
- .with(headers: auth_header)).to have_been_made
115
- end
116
-
117
- it 'updates api_key from responses with api_key header' do
118
- key = config.auth_settings['api_key'][:key]
119
- value = 'foo'
120
- auth_header = { key => value }
121
-
122
- stub_request(:get, url + '1').to_return(headers: auth_header)
123
- stub_request(:get, url + '2').with(headers: auth_header)
124
-
125
- subject.call_api(:GET, '/test1')
126
- subject.call_api(:GET, '/test2', auth_names: ['api_key'])
127
-
128
- expect(a_request(:get, url + '1')).to have_been_made
129
- expect(a_request(:get, url + '2')
130
- .with(headers: auth_header)).to have_been_made
131
- end
132
-
133
- it 'adds the body to requests when available' do
134
- body = { foo: 'bar' }.to_json
135
- stub_request(:post, url).with(body: body)
136
-
137
- subject.call_api(:POST, '/test', body: body)
138
-
139
- expect(a_request(:post, url).with(body: body)).to have_been_made
140
- end
141
-
142
- it 'sets the Content-Type on requests when available' do
143
- content_type = { 'Content-Type' => 'application/json' }
144
- body = { foo: 'bar' }.to_json
145
-
146
- stub_request(:post, url).with(body: body, headers: content_type)
147
-
148
- subject.call_api(:POST, '/test', body: body, header_params: content_type)
149
-
150
- expect(a_request(:post, url)
151
- .with(body: body, headers: content_type)).to have_been_made
152
- end
153
- end
154
-
155
- describe '#object_to_http_body' do
156
- context 'when given nil' do
157
- it 'returns the object as is' do
158
- expect(subject.object_to_http_body(nil)).to be_nil
159
- end
160
- end
161
-
162
- context 'when given a string' do
163
- it 'returns the object as is' do
164
- expect(subject.object_to_http_body('asdf')).to eq('asdf')
165
- end
166
- end
167
-
168
- context 'when given an object that responds to `to_hash`' do
169
- it 'returns that object as JSON' do
170
- obj = OpenStruct.new(foo: 'bar', baz: 'quux')
171
- obj.to_hash = obj.to_h
172
- json = obj.to_hash.to_json
173
-
174
- expect(subject.object_to_http_body(obj)).to eq(json)
175
- end
176
- end
177
-
178
- context 'when given an array' do
179
- it 'returns a JSON array of objects' do
180
- obj = OpenStruct.new(foo: 'bar', baz: 'quux')
181
- obj.to_hash = obj.to_h
182
- json = obj.to_hash.to_json
183
-
184
- expect(subject.object_to_http_body([obj])).to eq([json])
185
- end
186
- end
187
- end
188
-
189
- describe '#select_header_accept' do
190
- context 'when given anything other than an array' do
191
- it 'returns application/json as a default' do
192
- expect(subject.select_header_accept(nil)).to eq('application/json')
193
- expect(subject.select_header_accept('')).to eq('application/json')
194
- expect(subject.select_header_accept(1)).to eq('application/json')
195
- end
196
- end
197
-
198
- context 'when given a list of types' do
199
- context 'that includes a JSON type' do
200
- it 'returns the first type containing JSON' do
201
- xml = 'application/xml'
202
- json = 'application/json'
203
-
204
- expect(subject.select_header_accept([xml, json])).to eq(json)
205
- end
206
- end
207
-
208
- context 'that does not include a JSON type' do
209
- it 'returns the all of the types' do
210
- xml = 'application/xml'
211
- html = 'text/html'
212
- result = [xml, html].join(', ')
213
-
214
- expect(subject.select_header_accept([xml, html])).to eq(result)
215
- end
216
- end
217
- end
218
- end
219
-
220
- describe '#select_header_content_type' do
221
- context 'when given anything other than an array' do
222
- it 'returns application/json as a default' do
223
- expect(subject.select_header_content_type(nil)).to eq('application/json')
224
- expect(subject.select_header_content_type('')).to eq('application/json')
225
- expect(subject.select_header_content_type(1)).to eq('application/json')
226
- end
227
- end
228
-
229
- context 'when given a list of types' do
230
- context 'that includes a JSON type' do
231
- it 'returns the first type containing JSON' do
232
- xml = 'application/xml'
233
- json = 'application/json'
234
-
235
- expect(subject.select_header_content_type([xml, json])).to eq(json)
236
- end
237
- end
238
-
239
- context 'that does not include a JSON type' do
240
- it 'returns the first type' do
241
- xml = 'application/xml'
242
- html = 'text/html'
243
-
244
- expect(subject.select_header_content_type([xml, html])).to eq(xml)
245
- end
246
- end
247
- end
248
- end
249
- end
@@ -1,38 +0,0 @@
1
- # Copyright (c) 2018-2019 VMware, Inc. All Rights Reserved.
2
- # SPDX-License-Identifier: MIT
3
-
4
- # DO NOT MODIFY. THIS CODE IS GENERATED. CHANGES WILL BE OVERWRITTEN.
5
-
6
- # runtime - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
-
8
-
9
- require 'spec_helper'
10
-
11
- describe VSphereAutomation::Configuration do
12
- let(:config) { VSphereAutomation::Configuration.default }
13
-
14
- before(:each) do
15
- # uncomment below to setup host and base_path
16
- # require 'URI'
17
- # uri = URI.parse("https://<vcenter>/rest")
18
- # VSphereAutomation.configure do |c|
19
- # c.host = uri.host
20
- # c.base_path = uri.path
21
- # end
22
- end
23
-
24
- describe '#base_url' do
25
- it 'should have the default value' do
26
- # uncomment below to test default value of the base path
27
- # expect(config.base_url).to eq("https://<vcenter>/rest")
28
- end
29
-
30
- it 'should remove trailing slashes' do
31
- [nil, '', '/', '//'].each do |base_path|
32
- config.base_path = base_path
33
- # uncomment below to test trailing slashes
34
- # expect(config.base_url).to eq("https://<vcenter>/rest")
35
- end
36
- end
37
- end
38
- end
@@ -1,110 +0,0 @@
1
- # Copyright (c) 2018-2019 VMware, Inc. All Rights Reserved.
2
- # SPDX-License-Identifier: MIT
3
-
4
- # DO NOT MODIFY. THIS CODE IS GENERATED. CHANGES WILL BE OVERWRITTEN.
5
-
6
- # runtime - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
-
8
-
9
- # load the gem
10
- require 'vsphere-automation-runtime'
11
- require 'webmock/rspec'
12
-
13
- WebMock.disable_net_connect!(allow_localhost: true)
14
-
15
- # The following was generated by the `rspec --init` command. Conventionally, all
16
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
17
- # The generated `.rspec` file contains `--require spec_helper` which will cause
18
- # this file to always be loaded, without a need to explicitly require it in any
19
- # files.
20
- #
21
- # Given that it is always loaded, you are encouraged to keep this file as
22
- # light-weight as possible. Requiring heavyweight dependencies from this file
23
- # will add to the boot time of your test suite on EVERY test run, even for an
24
- # individual file that may not need all of that loaded. Instead, consider making
25
- # a separate helper file that requires the additional dependencies and performs
26
- # the additional setup, and require it from the spec files that actually need
27
- # it.
28
- #
29
- # The `.rspec` file also contains a few flags that are not defaults but that
30
- # users commonly want.
31
- #
32
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
33
- RSpec.configure do |config|
34
- # rspec-expectations config goes here. You can use an alternate
35
- # assertion/expectation library such as wrong or the stdlib/minitest
36
- # assertions if you prefer.
37
- config.expect_with :rspec do |expectations|
38
- # This option will default to `true` in RSpec 4. It makes the `description`
39
- # and `failure_message` of custom matchers include text for helper methods
40
- # defined using `chain`, e.g.:
41
- # be_bigger_than(2).and_smaller_than(4).description
42
- # # => "be bigger than 2 and smaller than 4"
43
- # ...rather than:
44
- # # => "be bigger than 2"
45
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
46
- end
47
-
48
- # rspec-mocks config goes here. You can use an alternate test double
49
- # library (such as bogus or mocha) by changing the `mock_with` option here.
50
- config.mock_with :rspec do |mocks|
51
- # Prevents you from mocking or stubbing a method that does not exist on
52
- # a real object. This is generally recommended, and will default to
53
- # `true` in RSpec 4.
54
- mocks.verify_partial_doubles = true
55
- end
56
-
57
- # The settings below are suggested to provide a good initial experience
58
- # with RSpec, but feel free to customize to your heart's content.
59
- =begin
60
- # These two settings work together to allow you to limit a spec run
61
- # to individual examples or groups you care about by tagging them with
62
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
63
- # get run.
64
- config.filter_run :focus
65
- config.run_all_when_everything_filtered = true
66
-
67
- # Allows RSpec to persist some state between runs in order to support
68
- # the `--only-failures` and `--next-failure` CLI options. We recommend
69
- # you configure your source control system to ignore this file.
70
- config.example_status_persistence_file_path = "spec/examples.txt"
71
-
72
- # Limits the available syntax to the non-monkey patched syntax that is
73
- # recommended. For more details, see:
74
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
75
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
76
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
77
- config.disable_monkey_patching!
78
-
79
- # This setting enables warnings. It's recommended, but in some cases may
80
- # be too noisy due to issues in dependencies.
81
- config.warnings = true
82
-
83
- # Many RSpec users commonly either run the entire suite or an individual
84
- # file, and it's useful to allow more verbose output when running an
85
- # individual spec file.
86
- if config.files_to_run.one?
87
- # Use the documentation formatter for detailed output,
88
- # unless a formatter has already been configured
89
- # (e.g. via a command-line flag).
90
- config.default_formatter = 'doc'
91
- end
92
-
93
- # Print the 10 slowest examples and example groups at the
94
- # end of the spec run, to help surface which specs are running
95
- # particularly slow.
96
- config.profile_examples = 10
97
-
98
- # Run specs in random order to surface order dependencies. If you find an
99
- # order dependency and want to debug it, you can fix the order by providing
100
- # the seed, which is printed after each run.
101
- # --seed 1234
102
- config.order = :random
103
-
104
- # Seed global randomization in this process using the `--seed` CLI option.
105
- # Setting this allows you to use `--seed` to deterministically reproduce
106
- # test failures related to randomization by passing the same `--seed` value
107
- # as the one that triggered the failure.
108
- Kernel.srand config.seed
109
- =end
110
- end