vsphere-automation-vapi 0.3.0 → 0.4.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6a8bd24821b0422524c268f415b68256c87c3c4b817c149125e3799947a21af
4
- data.tar.gz: 5983b8a6e59df79cfa51121f1b1af54ff994d5ba8dbc836c9d6d3d128c4074cc
3
+ metadata.gz: e8dcfd1374b6e9e34bc3f11c0a832bc6031fadb443c4b2986c41cd2809478735
4
+ data.tar.gz: d1da545b5207b73be26cf8d3dc689fe6a2f0624fe40ee1937ba98762238ed218
5
5
  SHA512:
6
- metadata.gz: 84ec0919fafd918bec533a946808aa36cbb47166e53a3beab527d1541f3f74f45814ce6f1ab68f9cde65a583ee1a71fc019410ef94f45c7146f0054f5210e35f
7
- data.tar.gz: 8a773e083ac6d60a4c93db44f5941ecc44bf54a9554c3d3b75c8809e3b1c5761e40f194984f0978109b330640a8e39bb026958f71bfdc6664642f650da445d8a
6
+ metadata.gz: 1ad0ff852a993f724f2eac896567b0982af3f88319bf5d593cb8ceede107471131d156a896af4d8ebc726e24012c09388b4cda139275f5adeb5e739b5f7cb44e
7
+ data.tar.gz: 2f5692d9211eac0b7a013f51d34e208c73496c27cdb0c2e4efa73a9a834392a7c1381f4582313e77f46684f39c9eaaa217dd73d9330a636f5e51de140c0f1673
@@ -1,45 +1,41 @@
1
1
  PATH
2
2
  remote: ../cis
3
3
  specs:
4
- vsphere-automation-cis (0.3.0)
5
- vsphere-automation-runtime (~> 0.3.0)
4
+ vsphere-automation-cis (0.4.4)
5
+ vsphere-automation-runtime (~> 0.4.4)
6
6
 
7
7
  PATH
8
8
  remote: ../runtime
9
9
  specs:
10
- vsphere-automation-runtime (0.3.0)
11
- typhoeus (~> 1.3)
10
+ vsphere-automation-runtime (0.4.4)
12
11
 
13
12
  PATH
14
13
  remote: .
15
14
  specs:
16
- vsphere-automation-vapi (0.3.0)
17
- vsphere-automation-cis (~> 0.3.0)
18
- vsphere-automation-runtime (~> 0.3.0)
15
+ vsphere-automation-vapi (0.4.4)
16
+ vsphere-automation-cis (~> 0.4.4)
17
+ vsphere-automation-runtime (~> 0.4.4)
19
18
 
20
19
  GEM
21
20
  remote: https://rubygems.org/
22
21
  specs:
23
- addressable (2.6.0)
24
- public_suffix (>= 2.0.2, < 4.0)
22
+ addressable (2.7.0)
23
+ public_suffix (>= 2.0.2, < 5.0)
25
24
  ast (2.4.0)
26
25
  coderay (1.1.2)
27
26
  crack (0.4.3)
28
27
  safe_yaml (~> 1.0.0)
29
28
  diff-lcs (1.3)
30
- ethon (0.12.0)
31
- ffi (>= 1.3.0)
32
- ffi (1.11.1)
33
29
  hashdiff (1.0.0)
34
30
  jaro_winkler (1.5.3)
35
31
  method_source (0.9.2)
36
32
  parallel (1.17.0)
37
- parser (2.6.3.0)
33
+ parser (2.6.5.0)
38
34
  ast (~> 2.4.0)
39
35
  pry (0.12.2)
40
36
  coderay (~> 1.1.0)
41
37
  method_source (~> 0.9.0)
42
- public_suffix (3.1.1)
38
+ public_suffix (4.0.1)
43
39
  rainbow (3.0.0)
44
40
  rake (12.3.3)
45
41
  rspec (3.8.0)
@@ -48,13 +44,13 @@ GEM
48
44
  rspec-mocks (~> 3.8.0)
49
45
  rspec-core (3.8.2)
50
46
  rspec-support (~> 3.8.0)
51
- rspec-expectations (3.8.4)
47
+ rspec-expectations (3.8.5)
52
48
  diff-lcs (>= 1.2.0, < 2.0)
53
49
  rspec-support (~> 3.8.0)
54
- rspec-mocks (3.8.1)
50
+ rspec-mocks (3.8.2)
55
51
  diff-lcs (>= 1.2.0, < 2.0)
56
52
  rspec-support (~> 3.8.0)
57
- rspec-support (3.8.2)
53
+ rspec-support (3.8.3)
58
54
  rubocop (0.73.0)
59
55
  jaro_winkler (~> 1.5.1)
60
56
  parallel (~> 1.10)
@@ -64,11 +60,9 @@ GEM
64
60
  unicode-display_width (>= 1.4.0, < 1.7)
65
61
  ruby-progressbar (1.10.1)
66
62
  safe_yaml (1.0.5)
67
- typhoeus (1.3.1)
68
- ethon (>= 0.9.0)
69
63
  unicode-display_width (1.6.0)
70
64
  vcr (5.0.0)
71
- webmock (3.6.2)
65
+ webmock (3.7.6)
72
66
  addressable (>= 2.3.6)
73
67
  crack (>= 0.3.2)
74
68
  hashdiff (>= 0.4.0, < 2.0.0)
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  The Ruby gem for the vSphere VAPI API
4
4
 
5
5
  - API version: 2.0.0
6
- - Package version: 0.3.0
6
+ - Package version: 0.4.4
7
7
 
8
8
  ## Installation
9
9
 
@@ -8,6 +8,6 @@
8
8
 
9
9
  module VSphereAutomation
10
10
  module VAPI
11
- VERSION = '0.3.0'
11
+ VERSION = '0.4.4'
12
12
  end
13
13
  end
@@ -31,7 +31,6 @@ describe 'MetadataAuthenticationComponentApi' do
31
31
  # unit tests for fingerprint
32
32
  # Retrieves the fingerprint computed from the authentication metadata of the component element corresponding to {@param.name componentId}. &lt;p&gt; The fingerprint provides clients an efficient way to check if the metadata for a particular component has been modified on the server. The client can do this by comparing the result of this operation with the fingerprint returned in the result of {@link vapi.metadata.authentication.Component#get}.
33
33
  # @param component_id Identifier of the component element.
34
- # @param action ~action&#x3D;fingerprint
35
34
  # @param [Hash] opts the optional parameters
36
35
  # @return [VapiMetadataAuthenticationComponentFingerprintResult]
37
36
  describe 'fingerprint test' do
@@ -31,7 +31,6 @@ describe 'MetadataAuthenticationServiceOperationApi' do
31
31
  # unit tests for get
32
32
  # Retrieves the authentication information about an operation element corresponding to {@param.name operationId} contained in the service element corresponding to {@param.name serviceId}.
33
33
  # @param service_id Identifier of the service element.
34
- # @param action ~action&#x3D;get
35
34
  # @param request_body
36
35
  # @param [Hash] opts the optional parameters
37
36
  # @return [VapiMetadataAuthenticationServiceOperationResult]
@@ -40,7 +40,6 @@ describe 'MetadataCliCommandApi' do
40
40
 
41
41
  # unit tests for get
42
42
  # Retrieves information about a command including information about how to execute that command.
43
- # @param action ~action&#x3D;get
44
43
  # @param request_body
45
44
  # @param [Hash] opts the optional parameters
46
45
  # @return [VapiMetadataCliCommandResult]
@@ -30,7 +30,6 @@ describe 'MetadataCliNamespaceApi' do
30
30
 
31
31
  # unit tests for fingerprint
32
32
  # Returns the aggregate fingerprint of all the namespace metadata from all the metadata sources. &lt;p&gt; The fingerprint provides clients an efficient way to check if the metadata for namespaces has been modified on the server.
33
- # @param action ~action&#x3D;fingerprint
34
33
  # @param [Hash] opts the optional parameters
35
34
  # @return [VapiMetadataCliNamespaceFingerprintResult]
36
35
  describe 'fingerprint test' do
@@ -31,7 +31,6 @@ describe 'MetadataMetamodelComponentApi' do
31
31
  # unit tests for fingerprint
32
32
  # Retrieves the fingerprint computed from the metamodel metadata of the component element corresponding to {@param.name componentId}. &lt;p&gt; The fingerprint provides clients an efficient way to check if the metadata for a particular component element has been modified on the server. The client can do this by comparing the result of this operation with the fingerprint returned in the result of {@link vapi.metadata.metamodel.Component#get}.
33
33
  # @param component_id Identifier of the component element.
34
- # @param action ~action&#x3D;fingerprint
35
34
  # @param [Hash] opts the optional parameters
36
35
  # @return [VapiMetadataMetamodelComponentFingerprintResult]
37
36
  describe 'fingerprint test' do
@@ -31,7 +31,6 @@ describe 'MetadataPrivilegeComponentApi' do
31
31
  # unit tests for fingerprint
32
32
  # Retrieves the fingerprint computed from the privilege metadata of the component element corresponding to {@param.name componentId}. &lt;p&gt; The fingerprint provides clients an efficient way to check if the metadata for a particular component has been modified on the server. The client can do this by comparing the result of this operation with the fingerprint returned in the result of {@link vapi.metadata.privilege.Component#get}.
33
33
  # @param component_id Identifier of the component element.
34
- # @param action ~action&#x3D;fingerprint
35
34
  # @param [Hash] opts the optional parameters
36
35
  # @return [VapiMetadataPrivilegeComponentFingerprintResult]
37
36
  describe 'fingerprint test' do
@@ -31,7 +31,6 @@ describe 'MetadataPrivilegeServiceOperationApi' do
31
31
  # unit tests for get
32
32
  # Retrieves the privilege information about an operation element corresponding to {@param.name operationId} contained in the service element corresponding to {@param.name serviceId}.
33
33
  # @param service_id Identifier of the service element.
34
- # @param action ~action&#x3D;get
35
34
  # @param request_body
36
35
  # @param [Hash] opts the optional parameters
37
36
  # @return [VapiMetadataPrivilegeServiceOperationResult]
@@ -30,7 +30,6 @@ describe 'RestNavigationOptionsApi' do
30
30
 
31
31
  # unit tests for get
32
32
  # Retrieves operations for specific URL.
33
- # @param action ~action&#x3D;get
34
33
  # @param request_body
35
34
  # @param [Hash] opts the optional parameters
36
35
  # @return [VapiRestNavigationOptionsResult]
@@ -31,7 +31,6 @@ describe 'VcenterActivationApi' do
31
31
  # unit tests for cancel
32
32
  # Sends a request to cancel the task associated with the provided {@param.name activationId}.
33
33
  # @param activation_id the {@param.name activationId} associated with a vCenter Server task to be canceled.
34
- # @param action ~action&#x3D;cancel
35
34
  # @param [Hash] opts the optional parameters
36
35
  # @return [nil]
37
36
  describe 'cancel test' do
@@ -8,6 +8,9 @@
8
8
 
9
9
  # load the gem
10
10
  require 'vsphere-automation-vapi'
11
+ require 'webmock/rspec'
12
+
13
+ WebMock.disable_net_connect!(allow_localhost: true)
11
14
 
12
15
  # The following was generated by the `rspec --init` command. Conventionally, all
13
16
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
@@ -22,9 +22,8 @@ Gem::Specification.new do |s|
22
22
  s.description = "A Ruby SDK for the vSphere APIs (VAPI)"
23
23
  s.license = 'MIT'
24
24
  s.required_ruby_version = ">= 2.3"
25
-
26
- s.add_runtime_dependency 'vsphere-automation-runtime', '~> 0.3.0'
27
- s.add_runtime_dependency 'vsphere-automation-cis', '~> 0.3.0'
25
+ s.add_runtime_dependency 'vsphere-automation-runtime', '~> 0.4.4'
26
+ s.add_runtime_dependency 'vsphere-automation-cis', '~> 0.4.4'
28
27
 
29
28
  s.add_development_dependency 'bundler', '~> 2.0'
30
29
  s.add_development_dependency 'pry', '~> 0.12.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vsphere-automation-vapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.R. Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-22 00:00:00.000000000 Z
11
+ date: 2019-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vsphere-automation-runtime
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.0
19
+ version: 0.4.4
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
- version: 0.3.0
26
+ version: 0.4.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: vsphere-automation-cis
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.3.0
33
+ version: 0.4.4
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
- version: 0.3.0
40
+ version: 0.4.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -328,9 +328,6 @@ files:
328
328
  - lib/vsphere-automation-vapi/api/rest_navigation_root_api.rb
329
329
  - lib/vsphere-automation-vapi/api/rest_navigation_service_api.rb
330
330
  - lib/vsphere-automation-vapi/api/vcenter_activation_api.rb
331
- - lib/vsphere-automation-vapi/api_client.rb
332
- - lib/vsphere-automation-vapi/api_error.rb
333
- - lib/vsphere-automation-vapi/configuration.rb
334
331
  - lib/vsphere-automation-vapi/models/vapi_metadata_authentication_authentication_info.rb
335
332
  - lib/vsphere-automation-vapi/models/vapi_metadata_authentication_authentication_info_scheme_type.rb
336
333
  - lib/vsphere-automation-vapi/models/vapi_metadata_authentication_component_data.rb
@@ -463,8 +460,9 @@ files:
463
460
  - lib/vsphere-automation-vapi/models/vapi_std_errors_unauthorized_error.rb
464
461
  - lib/vsphere-automation-vapi/models/vapi_std_localizable_message.rb
465
462
  - lib/vsphere-automation-vapi/version.rb
466
- - pkg/vsphere-automation-vapi-0.2.1.gem
467
- - pkg/vsphere-automation-vapi-0.2.2.gem
463
+ - pkg/vsphere-automation-vapi-0.4.1.gem
464
+ - pkg/vsphere-automation-vapi-0.4.2.gem
465
+ - pkg/vsphere-automation-vapi-0.4.3.gem
468
466
  - spec/api/metadata_authentication_component_api_spec.rb
469
467
  - spec/api/metadata_authentication_package_api_spec.rb
470
468
  - spec/api/metadata_authentication_service_api_spec.rb
@@ -489,8 +487,6 @@ files:
489
487
  - spec/api/rest_navigation_root_api_spec.rb
490
488
  - spec/api/rest_navigation_service_api_spec.rb
491
489
  - spec/api/vcenter_activation_api_spec.rb
492
- - spec/api_client_spec.rb
493
- - spec/configuration_spec.rb
494
490
  - spec/models/vapi_metadata_authentication_authentication_info_scheme_type_spec.rb
495
491
  - spec/models/vapi_metadata_authentication_authentication_info_spec.rb
496
492
  - spec/models/vapi_metadata_authentication_component_data_spec.rb
@@ -672,8 +668,6 @@ test_files:
672
668
  - spec/api/rest_navigation_root_api_spec.rb
673
669
  - spec/api/metadata_metamodel_resource_api_spec.rb
674
670
  - spec/api/vcenter_activation_api_spec.rb
675
- - spec/api_client_spec.rb
676
- - spec/configuration_spec.rb
677
671
  - spec/models/vapi_rest_navigation_link_spec.rb
678
672
  - spec/models/vapi_rest_navigation_root_result_spec.rb
679
673
  - spec/models/vapi_metadata_cli_command_formatter_type_spec.rb
@@ -1,390 +0,0 @@
1
- =begin
2
- # Copyright (c) 2018-2019 VMware, Inc. All Rights Reserved.
3
- # SPDX-License-Identifier: MIT
4
-
5
- # DO NOT MODIFY. THIS CODE IS GENERATED. CHANGES WILL BE OVERWRITTEN.
6
-
7
- # vapi - vAPI is an extensible API Platform for modelling and delivering APIs/SDKs/CLIs.
8
-
9
- =end
10
-
11
- require 'date'
12
- require 'json'
13
- require 'logger'
14
- require 'tempfile'
15
- require 'typhoeus'
16
- require 'uri'
17
-
18
- module VSphereAutomation
19
- class ApiClient
20
- # The Configuration object holding settings to be used in the API client.
21
- attr_accessor :config
22
-
23
- # Defines the headers to be used in HTTP requests of all API calls by default.
24
- #
25
- # @return [Hash]
26
- attr_accessor :default_headers
27
-
28
- # Initializes the ApiClient
29
- # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
30
- def initialize(config = Configuration.default)
31
- @config = config
32
- @user_agent = "SDK/0.3.0 Ruby/#{RUBY_VERSION} (#{Gem::Platform.local.os}; #{Gem::Platform.local.version}; #{Gem::Platform.local.cpu})"
33
- @default_headers = {
34
- 'Content-Type' => 'application/json',
35
- 'User-Agent' => @user_agent
36
- }
37
- end
38
-
39
- def self.default
40
- @@default ||= ApiClient.new
41
- end
42
-
43
- # Call an API with given options.
44
- #
45
- # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
46
- # the data deserialized from response body (could be nil), response status code and response headers.
47
- def call_api(http_method, path, opts = {})
48
- request = build_request(http_method, path, opts)
49
- response = request.run
50
-
51
- if @config.debugging
52
- @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
53
- end
54
-
55
- unless opts.fetch(:return_type, {}).keys.include?(response.code.to_s) || response.success?
56
- if response.timed_out?
57
- fail ApiError.new('Connection timed out')
58
- elsif response.code == 0
59
- # Errors from libcurl will be made visible here
60
- fail ApiError.new(:code => 0,
61
- :message => response.return_message)
62
- else
63
- fail ApiError.new(:code => response.code,
64
- :response_headers => response.headers,
65
- :response_body => response.body),
66
- response.status_message
67
- end
68
- end
69
-
70
- if opts[:return_type]
71
- data = deserialize(response, opts[:return_type][response.code.to_s])
72
- if path == '/com/vmware/cis/session'
73
- @config.api_key['vmware-api-session-id'] = data.value
74
- end
75
- else
76
- data = nil
77
- end
78
- return data, response.code, response.headers
79
- end
80
-
81
- # Builds the HTTP request
82
- #
83
- # @param [String] http_method HTTP method/verb (e.g. POST)
84
- # @param [String] path URL path (e.g. /account/new)
85
- # @option opts [Hash] :header_params Header parameters
86
- # @option opts [Hash] :query_params Query parameters
87
- # @option opts [Hash] :form_params Query parameters
88
- # @option opts [Object] :body HTTP body (JSON/XML)
89
- # @return [Typhoeus::Request] A Typhoeus Request
90
- def build_request(http_method, path, opts = {})
91
- url = build_request_url(path)
92
- http_method = http_method.to_sym.downcase
93
-
94
- header_params = @default_headers.merge(opts[:header_params] || {})
95
- query_params = opts[:query_params] || {}
96
- form_params = opts[:form_params] || {}
97
-
98
- update_params_for_auth! header_params, query_params, opts[:auth_names]
99
-
100
- # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
101
- _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
102
-
103
- req_opts = {
104
- :method => http_method,
105
- :headers => header_params,
106
- :params => query_params,
107
- :params_encoding => @config.params_encoding,
108
- :timeout => @config.timeout,
109
- :ssl_verifypeer => @config.verify_ssl,
110
- :ssl_verifyhost => _verify_ssl_host,
111
- :sslcert => @config.cert_file,
112
- :sslkey => @config.key_file,
113
- :verbose => @config.debugging
114
- }
115
-
116
- # set custom cert, if provided
117
- req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
118
-
119
- if [:post, :patch, :put, :delete].include?(http_method)
120
- req_body = build_request_body(header_params, form_params, opts[:body])
121
- req_opts.update :body => req_body
122
- if @config.debugging
123
- @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
124
- end
125
- end
126
-
127
- request = Typhoeus::Request.new(url, req_opts)
128
- download_file(request) if opts[:return_type] == 'File'
129
- request
130
- end
131
-
132
- # Check if the given MIME is a JSON MIME.
133
- # JSON MIME examples:
134
- # application/json
135
- # application/json; charset=UTF8
136
- # APPLICATION/JSON
137
- # */*
138
- # @param [String] mime MIME
139
- # @return [Boolean] True if the MIME is application/json
140
- def json_mime?(mime)
141
- (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
142
- end
143
-
144
- # Deserialize the response to the given return type.
145
- #
146
- # @param [Response] response HTTP response
147
- # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
148
- def deserialize(response, return_type)
149
- body = response.body
150
-
151
- # handle file downloading - return the File instance processed in request callbacks
152
- # note that response body is empty when the file is written in chunks in request on_body callback
153
- return @tempfile if return_type == 'File'
154
-
155
- return nil if body.nil? || body.empty?
156
-
157
- # return response body directly for String return type
158
- return body if return_type == 'String'
159
-
160
- # ensuring a default content type
161
- content_type = response.headers['Content-Type'] || 'application/json'
162
-
163
- fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
164
-
165
- begin
166
- data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
167
- rescue JSON::ParserError => e
168
- if %w(String Date DateTime).include?(return_type)
169
- data = body
170
- else
171
- raise e
172
- end
173
- end
174
-
175
- convert_to_type data, return_type
176
- end
177
-
178
- # Convert data to the given return type.
179
- # @param [Object] data Data to be converted
180
- # @param [String] return_type Return type
181
- # @return [Mixed] Data in a particular type
182
- def convert_to_type(data, return_type)
183
- return nil if data.nil?
184
- case return_type
185
- when 'String'
186
- data.to_s
187
- when 'Integer'
188
- data.to_i
189
- when 'Float'
190
- data.to_f
191
- when 'BOOLEAN'
192
- data == true
193
- when 'DateTime'
194
- # parse date time (expecting ISO 8601 format)
195
- DateTime.parse data
196
- when 'Date'
197
- # parse date time (expecting ISO 8601 format)
198
- Date.parse data
199
- when 'Object'
200
- # generic object (usually a Hash), return directly
201
- data
202
- when /\AArray<(.+)>\z/
203
- # e.g. Array<Pet>
204
- sub_type = $1
205
- data.map { |item| convert_to_type(item, sub_type) }
206
- when /\AHash\<String, (.+)\>\z/
207
- # e.g. Hash<String, Integer>
208
- sub_type = $1
209
- {}.tap do |hash|
210
- data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
211
- end
212
- else
213
- # models, e.g. Pet
214
- VSphereAutomation.const_get(return_type).new.tap do |model|
215
- model.build_from_hash data
216
- end
217
- end
218
- end
219
-
220
- # Save response body into a file in (the defined) temporary folder, using the filename
221
- # from the "Content-Disposition" header if provided, otherwise a random filename.
222
- # The response body is written to the file in chunks in order to handle files which
223
- # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
224
- # process can use.
225
- #
226
- # @see Configuration#temp_folder_path
227
- def download_file(request)
228
- tempfile = nil
229
- encoding = nil
230
- request.on_headers do |response|
231
- content_disposition = response.headers['Content-Disposition']
232
- if content_disposition && content_disposition =~ /filename=/i
233
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
234
- prefix = sanitize_filename(filename)
235
- else
236
- prefix = 'download-'
237
- end
238
- prefix = prefix + '-' unless prefix.end_with?('-')
239
- encoding = response.body.encoding
240
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
241
- @tempfile = tempfile
242
- end
243
- request.on_body do |chunk|
244
- chunk.force_encoding(encoding)
245
- tempfile.write(chunk)
246
- end
247
- request.on_complete do |response|
248
- tempfile.close
249
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
250
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
251
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
252
- "explicitly with `tempfile.delete`"
253
- end
254
- end
255
-
256
- # Sanitize filename by removing path.
257
- # e.g. ../../sun.gif becomes sun.gif
258
- #
259
- # @param [String] filename the filename to be sanitized
260
- # @return [String] the sanitized filename
261
- def sanitize_filename(filename)
262
- filename.gsub(/.*[\/\\]/, '')
263
- end
264
-
265
- def build_request_url(path)
266
- # Add leading and trailing slashes to path
267
- path = "/#{path}".gsub(/\/+/, '/')
268
- URI.encode(@config.base_url + path)
269
- end
270
-
271
- # Builds the HTTP request body
272
- #
273
- # @param [Hash] header_params Header parameters
274
- # @param [Hash] form_params Query parameters
275
- # @param [Object] body HTTP body (JSON/XML)
276
- # @return [String] HTTP body data in the form of string
277
- def build_request_body(header_params, form_params, body)
278
- # http form
279
- if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
280
- header_params['Content-Type'] == 'multipart/form-data'
281
- data = {}
282
- form_params.each do |key, value|
283
- case value
284
- when ::File, ::Array, nil
285
- # let typhoeus handle File, Array and nil parameters
286
- data[key] = value
287
- else
288
- data[key] = value.to_s
289
- end
290
- end
291
- elsif body
292
- data = body.is_a?(String) ? body : body.to_json
293
- else
294
- data = nil
295
- end
296
- data
297
- end
298
-
299
- # Update hearder and query params based on authentication settings.
300
- #
301
- # @param [Hash] header_params Header parameters
302
- # @param [Hash] query_params Query parameters
303
- # @param [String] auth_names Authentication scheme name
304
- def update_params_for_auth!(header_params, query_params, auth_names)
305
- Array(auth_names).each do |auth_name|
306
- auth_setting = @config.auth_settings[auth_name]
307
- next unless auth_setting
308
- case auth_setting[:in]
309
- when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
310
- when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
311
- else fail ArgumentError, 'Authentication token must be in `query` of `header`'
312
- end
313
- end
314
- end
315
-
316
- # Sets user agent in HTTP header
317
- #
318
- # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
319
- def user_agent=(user_agent)
320
- @user_agent = user_agent
321
- @default_headers['User-Agent'] = @user_agent
322
- end
323
-
324
- # Return Accept header based on an array of accepts provided.
325
- # @param [Array] accepts array for Accept
326
- # @return [String] the Accept header (e.g. application/json)
327
- def select_header_accept(accepts)
328
- return nil if accepts.nil? || accepts.empty?
329
- # use JSON when present, otherwise use all of the provided
330
- json_accept = accepts.find { |s| json_mime?(s) }
331
- json_accept || accepts.join(',')
332
- end
333
-
334
- # Return Content-Type header based on an array of content types provided.
335
- # @param [Array] content_types array for Content-Type
336
- # @return [String] the Content-Type header (e.g. application/json)
337
- def select_header_content_type(content_types)
338
- # use application/json by default
339
- return 'application/json' if content_types.nil? || content_types.empty?
340
- # use JSON when present, otherwise use the first one
341
- json_content_type = content_types.find { |s| json_mime?(s) }
342
- json_content_type || content_types.first
343
- end
344
-
345
- # Convert object (array, hash, object, etc) to JSON string.
346
- # @param [Object] model object to be converted into JSON string
347
- # @return [String] JSON string representation of the object
348
- def object_to_http_body(model)
349
- return model if model.nil? || model.is_a?(String)
350
- local_body = nil
351
- if model.is_a?(Array)
352
- local_body = model.map { |m| object_to_hash(m) }
353
- else
354
- local_body = object_to_hash(model)
355
- end
356
- local_body.to_json
357
- end
358
-
359
- # Convert object(non-array) to hash.
360
- # @param [Object] obj object to be converted into JSON string
361
- # @return [String] JSON string representation of the object
362
- def object_to_hash(obj)
363
- if obj.respond_to?(:to_hash)
364
- obj.to_hash
365
- else
366
- obj
367
- end
368
- end
369
-
370
- # Build parameter value according to the given collection format.
371
- # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
372
- def build_collection_param(param, collection_format)
373
- case collection_format
374
- when :csv
375
- param.join(',')
376
- when :ssv
377
- param.join(' ')
378
- when :tsv
379
- param.join("\t")
380
- when :pipes
381
- param.join('|')
382
- when :multi
383
- # return the array directly as typhoeus will handle it as expected
384
- param
385
- else
386
- fail "unknown collection format: #{collection_format.inspect}"
387
- end
388
- end
389
- end
390
- end
@@ -1,34 +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
- # vapi - vAPI is an extensible API Platform for modelling and delivering APIs/SDKs/CLIs.
7
-
8
-
9
- module VSphereAutomation
10
- class ApiError < StandardError
11
- attr_reader :code, :response_headers, :response_body
12
-
13
- # Usage examples:
14
- # ApiError.new
15
- # ApiError.new("message")
16
- # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
17
- # ApiError.new(:code => 404, :message => "Not Found")
18
- def initialize(arg = nil)
19
- if arg.is_a? Hash
20
- if arg.key?(:message) || arg.key?('message')
21
- super(arg[:message] || arg['message'])
22
- else
23
- super arg
24
- end
25
-
26
- arg.each do |k, v|
27
- instance_variable_set "@#{k}", v
28
- end
29
- else
30
- super arg
31
- end
32
- end
33
- end
34
- end
@@ -1,212 +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
- # vapi - vAPI is an extensible API Platform for modelling and delivering APIs/SDKs/CLIs.
7
-
8
-
9
- require 'uri'
10
-
11
- module VSphereAutomation
12
- class Configuration
13
- # Defines url scheme
14
- attr_accessor :scheme
15
-
16
- # Defines url host
17
- attr_accessor :host
18
-
19
- # Defines url base path
20
- attr_accessor :base_path
21
-
22
- # Defines API keys used with API Key authentications.
23
- #
24
- # @return [Hash] key: parameter name, value: parameter value (API key)
25
- #
26
- # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
27
- # config.api_key['api_key'] = 'xxx'
28
- attr_accessor :api_key
29
-
30
- # Defines API key prefixes used with API Key authentications.
31
- #
32
- # @return [Hash] key: parameter name, value: API key prefix
33
- #
34
- # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
35
- # config.api_key_prefix['api_key'] = 'Token'
36
- attr_accessor :api_key_prefix
37
-
38
- # Defines the username used with HTTP basic authentication.
39
- #
40
- # @return [String]
41
- attr_accessor :username
42
-
43
- # Defines the password used with HTTP basic authentication.
44
- #
45
- # @return [String]
46
- attr_accessor :password
47
-
48
- # Defines the access token (Bearer) used with OAuth2.
49
- attr_accessor :access_token
50
-
51
- # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
52
- # details will be logged with `logger.debug` (see the `logger` attribute).
53
- # Default to false.
54
- #
55
- # @return [true, false]
56
- attr_accessor :debugging
57
-
58
- # Defines the logger used for debugging.
59
- # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
60
- #
61
- # @return [#debug]
62
- attr_accessor :logger
63
-
64
- # Defines the temporary folder to store downloaded files
65
- # (for API endpoints that have file response).
66
- # Default to use `Tempfile`.
67
- #
68
- # @return [String]
69
- attr_accessor :temp_folder_path
70
-
71
- # The time limit for HTTP request in seconds.
72
- # Default to 0 (never times out).
73
- attr_accessor :timeout
74
-
75
- # Set this to false to skip client side validation in the operation.
76
- # Default to true.
77
- # @return [true, false]
78
- attr_accessor :client_side_validation
79
-
80
- ### TLS/SSL setting
81
- # Set this to false to skip verifying SSL certificate when calling API from https server.
82
- # Default to true.
83
- #
84
- # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
85
- #
86
- # @return [true, false]
87
- attr_accessor :verify_ssl
88
-
89
- ### TLS/SSL setting
90
- # Set this to false to skip verifying SSL host name
91
- # Default to true.
92
- #
93
- # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
94
- #
95
- # @return [true, false]
96
- attr_accessor :verify_ssl_host
97
-
98
- ### TLS/SSL setting
99
- # Set this to customize the certificate file to verify the peer.
100
- #
101
- # @return [String] the path to the certificate file
102
- #
103
- # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
104
- # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
105
- attr_accessor :ssl_ca_cert
106
-
107
- ### TLS/SSL setting
108
- # Client certificate file (for client certificate)
109
- attr_accessor :cert_file
110
-
111
- ### TLS/SSL setting
112
- # Client private key file (for client certificate)
113
- attr_accessor :key_file
114
-
115
- # Set this to customize parameters encoding of array parameter with multi collectionFormat.
116
- # Default to nil.
117
- #
118
- # @see The params_encoding option of Ethon. Related source code:
119
- # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
120
- attr_accessor :params_encoding
121
-
122
- attr_accessor :inject_format
123
-
124
- attr_accessor :force_ending_format
125
-
126
- def initialize
127
- @scheme = 'https'
128
- @host = '&lt;vcenter&gt;'
129
- @base_path = '/rest'
130
- @api_key = {}
131
- @api_key_prefix = {}
132
- @timeout = 0
133
- @client_side_validation = true
134
- @verify_ssl = true
135
- @verify_ssl_host = true
136
- @params_encoding = :multi
137
- @cert_file = nil
138
- @key_file = nil
139
- @debugging = false
140
- @inject_format = false
141
- @force_ending_format = false
142
- @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
143
-
144
- yield(self) if block_given?
145
- end
146
-
147
- # The default Configuration object.
148
- def self.default
149
- @@default ||= Configuration.new
150
- end
151
-
152
- def configure
153
- yield(self) if block_given?
154
- end
155
-
156
- def scheme=(scheme)
157
- # remove :// from scheme
158
- @scheme = scheme.sub(/:\/\//, '')
159
- end
160
-
161
- def host=(host)
162
- # remove http(s):// and anything after a slash
163
- @host = host.sub(/https?:\/\//, '').split('/').first
164
- end
165
-
166
- def base_path=(base_path)
167
- # Add leading and trailing slashes to base_path
168
- @base_path = "/#{base_path}".gsub(/\/+/, '/')
169
- @base_path = '' if @base_path == '/'
170
- end
171
-
172
- def base_url
173
- url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
174
- URI.encode(url)
175
- end
176
-
177
- # Gets API key (with prefix if set).
178
- # @param [String] param_name the parameter name of API key auth
179
- def api_key_with_prefix(param_name)
180
- if @api_key_prefix[param_name]
181
- "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
182
- else
183
- @api_key[param_name]
184
- end
185
- end
186
-
187
- # Gets Basic Auth token string
188
- def basic_auth_token
189
- 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
190
- end
191
-
192
- # Returns Auth Settings hash for api client.
193
- def auth_settings
194
- {
195
- 'api_key' =>
196
- {
197
- type: 'api_key',
198
- in: 'header',
199
- key: 'vmware-api-session-id',
200
- value: api_key_with_prefix('vmware-api-session-id')
201
- },
202
- 'basic_auth' =>
203
- {
204
- type: 'basic',
205
- in: 'header',
206
- key: 'Authorization',
207
- value: basic_auth_token
208
- },
209
- }
210
- end
211
- end
212
- end
@@ -1,222 +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
- # vapi - vAPI is an extensible API Platform for modelling and delivering APIs/SDKs/CLIs.
7
-
8
-
9
- require 'spec_helper'
10
-
11
- describe VSphereAutomation::ApiClient do
12
- context 'initialization' do
13
- context 'URL stuff' do
14
- context 'host' do
15
- it 'removes http from host' do
16
- VSphereAutomation.configure { |c| c.host = 'http://example.com' }
17
- expect(VSphereAutomation::Configuration.default.host).to eq('example.com')
18
- end
19
-
20
- it 'removes https from host' do
21
- VSphereAutomation.configure { |c| c.host = 'https://wookiee.com' }
22
- expect(VSphereAutomation::ApiClient.default.config.host).to eq('wookiee.com')
23
- end
24
-
25
- it 'removes trailing path from host' do
26
- VSphereAutomation.configure { |c| c.host = 'hobo.com/v4' }
27
- expect(VSphereAutomation::Configuration.default.host).to eq('hobo.com')
28
- end
29
- end
30
-
31
- context 'base_path' do
32
- it "prepends a slash to base_path" do
33
- VSphereAutomation.configure { |c| c.base_path = 'v4/dog' }
34
- expect(VSphereAutomation::Configuration.default.base_path).to eq('/v4/dog')
35
- end
36
-
37
- it "doesn't prepend a slash if one is already there" do
38
- VSphereAutomation.configure { |c| c.base_path = '/v4/dog' }
39
- expect(VSphereAutomation::Configuration.default.base_path).to eq('/v4/dog')
40
- end
41
-
42
- it "ends up as a blank string if nil" do
43
- VSphereAutomation.configure { |c| c.base_path = nil }
44
- expect(VSphereAutomation::Configuration.default.base_path).to eq('')
45
- end
46
- end
47
- end
48
- end
49
-
50
- describe 'params_encoding in #build_request' do
51
- let(:config) { VSphereAutomation::Configuration.new }
52
- let(:api_client) { VSphereAutomation::ApiClient.new(config) }
53
-
54
- it 'defaults to nil' do
55
- expect(VSphereAutomation::Configuration.default.params_encoding).to eq(nil)
56
- expect(config.params_encoding).to eq(nil)
57
-
58
- request = api_client.build_request(:get, '/test')
59
- expect(request.options[:params_encoding]).to eq(nil)
60
- end
61
-
62
- it 'can be customized' do
63
- config.params_encoding = :multi
64
- request = api_client.build_request(:get, '/test')
65
- expect(request.options[:params_encoding]).to eq(:multi)
66
- end
67
- end
68
-
69
- describe 'timeout in #build_request' do
70
- let(:config) { VSphereAutomation::Configuration.new }
71
- let(:api_client) { VSphereAutomation::ApiClient.new(config) }
72
-
73
- it 'defaults to 0' do
74
- expect(VSphereAutomation::Configuration.default.timeout).to eq(0)
75
- expect(config.timeout).to eq(0)
76
-
77
- request = api_client.build_request(:get, '/test')
78
- expect(request.options[:timeout]).to eq(0)
79
- end
80
-
81
- it 'can be customized' do
82
- config.timeout = 100
83
- request = api_client.build_request(:get, '/test')
84
- expect(request.options[:timeout]).to eq(100)
85
- end
86
- end
87
-
88
- describe '#deserialize' do
89
- it "handles Array<Integer>" do
90
- api_client = VSphereAutomation::ApiClient.new
91
- headers = { 'Content-Type' => 'application/json' }
92
- response = double('response', headers: headers, body: '[12, 34]')
93
- data = api_client.deserialize(response, 'Array<Integer>')
94
- expect(data).to be_instance_of(Array)
95
- expect(data).to eq([12, 34])
96
- end
97
-
98
- it 'handles Array<Array<Integer>>' do
99
- api_client = VSphereAutomation::ApiClient.new
100
- headers = { 'Content-Type' => 'application/json' }
101
- response = double('response', headers: headers, body: '[[12, 34], [56]]')
102
- data = api_client.deserialize(response, 'Array<Array<Integer>>')
103
- expect(data).to be_instance_of(Array)
104
- expect(data).to eq([[12, 34], [56]])
105
- end
106
-
107
- it 'handles Hash<String, String>' do
108
- api_client = VSphereAutomation::ApiClient.new
109
- headers = { 'Content-Type' => 'application/json' }
110
- response = double('response', headers: headers, body: '{"message": "Hello"}')
111
- data = api_client.deserialize(response, 'Hash<String, String>')
112
- expect(data).to be_instance_of(Hash)
113
- expect(data).to eq(:message => 'Hello')
114
- end
115
- end
116
-
117
- describe "#object_to_hash" do
118
- it 'ignores nils and includes empty arrays' do
119
- # uncomment below to test object_to_hash for model
120
- # api_client = VSphereAutomation::ApiClient.new
121
- # _model = VSphereAutomation::ModelName.new
122
- # update the model attribute below
123
- # _model.id = 1
124
- # update the expected value (hash) below
125
- # expected = {id: 1, name: '', tags: []}
126
- # expect(api_client.object_to_hash(_model)).to eq(expected)
127
- end
128
- end
129
-
130
- describe '#build_collection_param' do
131
- let(:param) { ['aa', 'bb', 'cc'] }
132
- let(:api_client) { VSphereAutomation::ApiClient.new }
133
-
134
- it 'works for csv' do
135
- expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
136
- end
137
-
138
- it 'works for ssv' do
139
- expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
140
- end
141
-
142
- it 'works for tsv' do
143
- expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
144
- end
145
-
146
- it 'works for pipes' do
147
- expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
148
- end
149
-
150
- it 'works for multi' do
151
- expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
152
- end
153
-
154
- it 'fails for invalid collection format' do
155
- expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
156
- end
157
- end
158
-
159
- describe '#json_mime?' do
160
- let(:api_client) { VSphereAutomation::ApiClient.new }
161
-
162
- it 'works' do
163
- expect(api_client.json_mime?(nil)).to eq false
164
- expect(api_client.json_mime?('')).to eq false
165
-
166
- expect(api_client.json_mime?('application/json')).to eq true
167
- expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
168
- expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
169
-
170
- expect(api_client.json_mime?('application/xml')).to eq false
171
- expect(api_client.json_mime?('text/plain')).to eq false
172
- expect(api_client.json_mime?('application/jsonp')).to eq false
173
- end
174
- end
175
-
176
- describe '#select_header_accept' do
177
- let(:api_client) { VSphereAutomation::ApiClient.new }
178
-
179
- it 'works' do
180
- expect(api_client.select_header_accept(nil)).to be_nil
181
- expect(api_client.select_header_accept([])).to be_nil
182
-
183
- expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
184
- expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
185
- expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
186
-
187
- expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
188
- expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
189
- end
190
- end
191
-
192
- describe '#select_header_content_type' do
193
- let(:api_client) { VSphereAutomation::ApiClient.new }
194
-
195
- it 'works' do
196
- expect(api_client.select_header_content_type(nil)).to eq('application/json')
197
- expect(api_client.select_header_content_type([])).to eq('application/json')
198
-
199
- expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
200
- expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
201
- expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
202
- expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
203
- expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
204
- end
205
- end
206
-
207
- describe '#sanitize_filename' do
208
- let(:api_client) { VSphereAutomation::ApiClient.new }
209
-
210
- it 'works' do
211
- expect(api_client.sanitize_filename('sun')).to eq('sun')
212
- expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
213
- expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
214
- expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
215
- expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
216
- expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
217
- expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
218
- expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
219
- expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
220
- end
221
- end
222
- 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
- # vapi - vAPI is an extensible API Platform for modelling and delivering APIs/SDKs/CLIs.
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