vsphere-automation-cis 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +20 -0
  3. data/lib/vsphere-automation-cis/version.rb +1 -1
  4. metadata +6 -286
  5. data/Gemfile +0 -13
  6. data/Gemfile.lock +0 -78
  7. data/README.md +0 -180
  8. data/Rakefile +0 -18
  9. data/docs/CisSessionCreateResult.md +0 -8
  10. data/docs/CisSessionInfo.md +0 -10
  11. data/docs/CisSessionResult.md +0 -8
  12. data/docs/CisTaggingCategoryAddToUsedBy.md +0 -8
  13. data/docs/CisTaggingCategoryCreate.md +0 -8
  14. data/docs/CisTaggingCategoryCreateResult.md +0 -8
  15. data/docs/CisTaggingCategoryCreateSpec.md +0 -12
  16. data/docs/CisTaggingCategoryListResult.md +0 -8
  17. data/docs/CisTaggingCategoryListUsedCategories.md +0 -8
  18. data/docs/CisTaggingCategoryListUsedCategoriesResult.md +0 -8
  19. data/docs/CisTaggingCategoryModel.md +0 -13
  20. data/docs/CisTaggingCategoryModelCardinality.md +0 -7
  21. data/docs/CisTaggingCategoryRemoveFromUsedBy.md +0 -8
  22. data/docs/CisTaggingCategoryResult.md +0 -8
  23. data/docs/CisTaggingCategoryUpdate.md +0 -8
  24. data/docs/CisTaggingCategoryUpdateSpec.md +0 -11
  25. data/docs/CisTaggingTagAddToUsedBy.md +0 -8
  26. data/docs/CisTaggingTagAssociationAttach.md +0 -8
  27. data/docs/CisTaggingTagAssociationAttachMultipleTagsToObject.md +0 -9
  28. data/docs/CisTaggingTagAssociationAttachMultipleTagsToObjectResult.md +0 -8
  29. data/docs/CisTaggingTagAssociationAttachTagToMultipleObjects.md +0 -8
  30. data/docs/CisTaggingTagAssociationAttachTagToMultipleObjectsResult.md +0 -8
  31. data/docs/CisTaggingTagAssociationBatchResult.md +0 -9
  32. data/docs/CisTaggingTagAssociationDetach.md +0 -8
  33. data/docs/CisTaggingTagAssociationDetachMultipleTagsFromObject.md +0 -9
  34. data/docs/CisTaggingTagAssociationDetachMultipleTagsFromObjectResult.md +0 -8
  35. data/docs/CisTaggingTagAssociationDetachTagFromMultipleObjects.md +0 -8
  36. data/docs/CisTaggingTagAssociationDetachTagFromMultipleObjectsResult.md +0 -8
  37. data/docs/CisTaggingTagAssociationListAttachableTags.md +0 -8
  38. data/docs/CisTaggingTagAssociationListAttachableTagsResult.md +0 -8
  39. data/docs/CisTaggingTagAssociationListAttachedObjectsOnTags.md +0 -8
  40. data/docs/CisTaggingTagAssociationListAttachedObjectsOnTagsResult.md +0 -8
  41. data/docs/CisTaggingTagAssociationListAttachedObjectsResult.md +0 -8
  42. data/docs/CisTaggingTagAssociationListAttachedTags.md +0 -8
  43. data/docs/CisTaggingTagAssociationListAttachedTagsOnObjects.md +0 -8
  44. data/docs/CisTaggingTagAssociationListAttachedTagsOnObjectsResult.md +0 -8
  45. data/docs/CisTaggingTagAssociationListAttachedTagsResult.md +0 -8
  46. data/docs/CisTaggingTagAssociationObjectToTags.md +0 -9
  47. data/docs/CisTaggingTagAssociationTagToObjects.md +0 -9
  48. data/docs/CisTaggingTagCreate.md +0 -8
  49. data/docs/CisTaggingTagCreateResult.md +0 -8
  50. data/docs/CisTaggingTagCreateSpec.md +0 -11
  51. data/docs/CisTaggingTagListResult.md +0 -8
  52. data/docs/CisTaggingTagListTagsForCategoryResult.md +0 -8
  53. data/docs/CisTaggingTagListUsedTags.md +0 -8
  54. data/docs/CisTaggingTagListUsedTagsResult.md +0 -8
  55. data/docs/CisTaggingTagModel.md +0 -12
  56. data/docs/CisTaggingTagRemoveFromUsedBy.md +0 -8
  57. data/docs/CisTaggingTagResult.md +0 -8
  58. data/docs/CisTaggingTagUpdate.md +0 -8
  59. data/docs/CisTaggingTagUpdateSpec.md +0 -9
  60. data/docs/CisTaskInfo.md +0 -19
  61. data/docs/CisTaskProgress.md +0 -10
  62. data/docs/CisTaskStatus.md +0 -7
  63. data/docs/CisTasksFilterSpec.md +0 -12
  64. data/docs/CisTasksGetSpec.md +0 -9
  65. data/docs/CisTasksListResult.md +0 -8
  66. data/docs/CisTasksListResultValue.md +0 -9
  67. data/docs/CisTasksResult.md +0 -8
  68. data/docs/FilterSpecTargets.md +0 -9
  69. data/docs/SessionApi.md +0 -151
  70. data/docs/TaggingCategoryApi.md +0 -464
  71. data/docs/TaggingTagApi.md +0 -515
  72. data/docs/TaggingTagAssociationApi.md +0 -575
  73. data/docs/TasksApi.md +0 -180
  74. data/docs/VapiStdDynamicID.md +0 -9
  75. data/docs/VapiStdErrorsAlreadyExists.md +0 -9
  76. data/docs/VapiStdErrorsAlreadyExistsError.md +0 -9
  77. data/docs/VapiStdErrorsError.md +0 -9
  78. data/docs/VapiStdErrorsErrorError.md +0 -9
  79. data/docs/VapiStdErrorsInvalidArgument.md +0 -9
  80. data/docs/VapiStdErrorsInvalidArgumentError.md +0 -9
  81. data/docs/VapiStdErrorsNotAllowedInCurrentState.md +0 -9
  82. data/docs/VapiStdErrorsNotAllowedInCurrentStateError.md +0 -9
  83. data/docs/VapiStdErrorsNotFound.md +0 -9
  84. data/docs/VapiStdErrorsNotFoundError.md +0 -9
  85. data/docs/VapiStdErrorsResourceInaccessible.md +0 -9
  86. data/docs/VapiStdErrorsResourceInaccessibleError.md +0 -9
  87. data/docs/VapiStdErrorsServiceUnavailable.md +0 -9
  88. data/docs/VapiStdErrorsServiceUnavailableError.md +0 -9
  89. data/docs/VapiStdErrorsUnauthenticated.md +0 -9
  90. data/docs/VapiStdErrorsUnauthenticatedError.md +0 -9
  91. data/docs/VapiStdErrorsUnauthorized.md +0 -9
  92. data/docs/VapiStdErrorsUnauthorizedError.md +0 -9
  93. data/docs/VapiStdErrorsUnsupported.md +0 -9
  94. data/docs/VapiStdErrorsUnsupportedError.md +0 -9
  95. data/docs/VapiStdLocalizableMessage.md +0 -10
  96. data/git_push.sh +0 -55
  97. data/lib/vsphere-automation-cis/api_client.rb +0 -260
  98. data/lib/vsphere-automation-cis/api_error.rb +0 -34
  99. data/lib/vsphere-automation-cis/configuration.rb +0 -212
  100. data/pkg/vsphere-automation-cis-0.4.1.gem +0 -0
  101. data/pkg/vsphere-automation-cis-0.4.2.gem +0 -0
  102. data/pkg/vsphere-automation-cis-0.4.3.gem +0 -0
  103. data/pkg/vsphere-automation-cis-0.4.4.gem +0 -0
  104. data/pkg/vsphere-automation-cis-0.4.5.gem +0 -0
  105. data/spec/api/session_api_spec.rb +0 -62
  106. data/spec/api/tagging_category_api_spec.rb +0 -132
  107. data/spec/api/tagging_tag_api_spec.rb +0 -143
  108. data/spec/api/tagging_tag_association_api_spec.rb +0 -156
  109. data/spec/api/tasks_api_spec.rb +0 -72
  110. data/spec/api_client_spec.rb +0 -248
  111. data/spec/configuration_spec.rb +0 -38
  112. data/spec/models/cis_session_create_result_spec.rb +0 -37
  113. data/spec/models/cis_session_info_spec.rb +0 -49
  114. data/spec/models/cis_session_result_spec.rb +0 -37
  115. data/spec/models/cis_tagging_category_add_to_used_by_spec.rb +0 -37
  116. data/spec/models/cis_tagging_category_create_result_spec.rb +0 -37
  117. data/spec/models/cis_tagging_category_create_spec.rb +0 -37
  118. data/spec/models/cis_tagging_category_create_spec_spec.rb +0 -61
  119. data/spec/models/cis_tagging_category_list_result_spec.rb +0 -37
  120. data/spec/models/cis_tagging_category_list_used_categories_result_spec.rb +0 -37
  121. data/spec/models/cis_tagging_category_list_used_categories_spec.rb +0 -37
  122. data/spec/models/cis_tagging_category_model_cardinality_spec.rb +0 -31
  123. data/spec/models/cis_tagging_category_model_spec.rb +0 -67
  124. data/spec/models/cis_tagging_category_remove_from_used_by_spec.rb +0 -37
  125. data/spec/models/cis_tagging_category_result_spec.rb +0 -37
  126. data/spec/models/cis_tagging_category_update_spec.rb +0 -37
  127. data/spec/models/cis_tagging_category_update_spec_spec.rb +0 -55
  128. data/spec/models/cis_tagging_tag_add_to_used_by_spec.rb +0 -37
  129. data/spec/models/cis_tagging_tag_association_attach_multiple_tags_to_object_result_spec.rb +0 -37
  130. data/spec/models/cis_tagging_tag_association_attach_multiple_tags_to_object_spec.rb +0 -43
  131. data/spec/models/cis_tagging_tag_association_attach_spec.rb +0 -37
  132. data/spec/models/cis_tagging_tag_association_attach_tag_to_multiple_objects_result_spec.rb +0 -37
  133. data/spec/models/cis_tagging_tag_association_attach_tag_to_multiple_objects_spec.rb +0 -37
  134. data/spec/models/cis_tagging_tag_association_batch_result_spec.rb +0 -43
  135. data/spec/models/cis_tagging_tag_association_detach_multiple_tags_from_object_result_spec.rb +0 -37
  136. data/spec/models/cis_tagging_tag_association_detach_multiple_tags_from_object_spec.rb +0 -43
  137. data/spec/models/cis_tagging_tag_association_detach_spec.rb +0 -37
  138. data/spec/models/cis_tagging_tag_association_detach_tag_from_multiple_objects_result_spec.rb +0 -37
  139. data/spec/models/cis_tagging_tag_association_detach_tag_from_multiple_objects_spec.rb +0 -37
  140. data/spec/models/cis_tagging_tag_association_list_attachable_tags_result_spec.rb +0 -37
  141. data/spec/models/cis_tagging_tag_association_list_attachable_tags_spec.rb +0 -37
  142. data/spec/models/cis_tagging_tag_association_list_attached_objects_on_tags_result_spec.rb +0 -37
  143. data/spec/models/cis_tagging_tag_association_list_attached_objects_on_tags_spec.rb +0 -37
  144. data/spec/models/cis_tagging_tag_association_list_attached_objects_result_spec.rb +0 -37
  145. data/spec/models/cis_tagging_tag_association_list_attached_tags_on_objects_result_spec.rb +0 -37
  146. data/spec/models/cis_tagging_tag_association_list_attached_tags_on_objects_spec.rb +0 -37
  147. data/spec/models/cis_tagging_tag_association_list_attached_tags_result_spec.rb +0 -37
  148. data/spec/models/cis_tagging_tag_association_list_attached_tags_spec.rb +0 -37
  149. data/spec/models/cis_tagging_tag_association_object_to_tags_spec.rb +0 -43
  150. data/spec/models/cis_tagging_tag_association_tag_to_objects_spec.rb +0 -43
  151. data/spec/models/cis_tagging_tag_create_result_spec.rb +0 -37
  152. data/spec/models/cis_tagging_tag_create_spec.rb +0 -37
  153. data/spec/models/cis_tagging_tag_create_spec_spec.rb +0 -55
  154. data/spec/models/cis_tagging_tag_list_result_spec.rb +0 -37
  155. data/spec/models/cis_tagging_tag_list_tags_for_category_result_spec.rb +0 -37
  156. data/spec/models/cis_tagging_tag_list_used_tags_result_spec.rb +0 -37
  157. data/spec/models/cis_tagging_tag_list_used_tags_spec.rb +0 -37
  158. data/spec/models/cis_tagging_tag_model_spec.rb +0 -61
  159. data/spec/models/cis_tagging_tag_remove_from_used_by_spec.rb +0 -37
  160. data/spec/models/cis_tagging_tag_result_spec.rb +0 -37
  161. data/spec/models/cis_tagging_tag_update_spec.rb +0 -37
  162. data/spec/models/cis_tagging_tag_update_spec_spec.rb +0 -43
  163. data/spec/models/cis_task_info_spec.rb +0 -103
  164. data/spec/models/cis_task_progress_spec.rb +0 -49
  165. data/spec/models/cis_task_status_spec.rb +0 -31
  166. data/spec/models/cis_tasks_filter_spec_spec.rb +0 -61
  167. data/spec/models/cis_tasks_get_spec_spec.rb +0 -43
  168. data/spec/models/cis_tasks_list_result_spec.rb +0 -37
  169. data/spec/models/cis_tasks_list_result_value_spec.rb +0 -43
  170. data/spec/models/cis_tasks_result_spec.rb +0 -37
  171. data/spec/models/filter_spec_targets_spec.rb +0 -43
  172. data/spec/models/vapi_std_dynamic_id_spec.rb +0 -43
  173. data/spec/models/vapi_std_errors_already_exists_error_spec.rb +0 -43
  174. data/spec/models/vapi_std_errors_already_exists_spec.rb +0 -43
  175. data/spec/models/vapi_std_errors_error_error_spec.rb +0 -43
  176. data/spec/models/vapi_std_errors_error_spec.rb +0 -43
  177. data/spec/models/vapi_std_errors_invalid_argument_error_spec.rb +0 -43
  178. data/spec/models/vapi_std_errors_invalid_argument_spec.rb +0 -43
  179. data/spec/models/vapi_std_errors_not_allowed_in_current_state_error_spec.rb +0 -43
  180. data/spec/models/vapi_std_errors_not_allowed_in_current_state_spec.rb +0 -43
  181. data/spec/models/vapi_std_errors_not_found_error_spec.rb +0 -43
  182. data/spec/models/vapi_std_errors_not_found_spec.rb +0 -43
  183. data/spec/models/vapi_std_errors_resource_inaccessible_error_spec.rb +0 -43
  184. data/spec/models/vapi_std_errors_resource_inaccessible_spec.rb +0 -43
  185. data/spec/models/vapi_std_errors_service_unavailable_error_spec.rb +0 -43
  186. data/spec/models/vapi_std_errors_service_unavailable_spec.rb +0 -43
  187. data/spec/models/vapi_std_errors_unauthenticated_error_spec.rb +0 -43
  188. data/spec/models/vapi_std_errors_unauthenticated_spec.rb +0 -43
  189. data/spec/models/vapi_std_errors_unauthorized_error_spec.rb +0 -43
  190. data/spec/models/vapi_std_errors_unauthorized_spec.rb +0 -43
  191. data/spec/models/vapi_std_errors_unsupported_error_spec.rb +0 -43
  192. data/spec/models/vapi_std_errors_unsupported_spec.rb +0 -43
  193. data/spec/models/vapi_std_localizable_message_spec.rb +0 -49
  194. data/spec/spec_helper.rb +0 -110
  195. data/vsphere-automation-cis.gemspec +0 -39
@@ -1,260 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'logger'
5
- require 'net/http'
6
- require 'openssl'
7
- require 'uri'
8
- require 'vsphere-automation-runtime/configuration'
9
- require 'vsphere-automation-runtime/version'
10
-
11
- module VSphereAutomation
12
- # The client responsible for communicating with the API.
13
- class ApiClient
14
- # The Configuration object holding settings to be used in the API client.
15
- attr_accessor :config
16
-
17
- # Defines the headers to be used in HTTP requests of all API calls by
18
- # default.
19
- #
20
- # @return [Hash]
21
- attr_reader :default_headers
22
-
23
- # Creates a new instance
24
- #
25
- # @param config [Configuration] configuration object with values to use
26
- def initialize(config = Configuration.default)
27
- @config = config
28
- @http = create_http
29
- @user_agent = default_user_agent
30
- @default_headers = { 'Content-Type' => 'application/json',
31
- 'User-Agent' => @user_agent }
32
- end
33
-
34
- # Retrieves an instance of the object in it's default state
35
- #
36
- # @return [ApiClient] an instance of the object in it's default state
37
- def self.default
38
- DEFAULT
39
- end
40
-
41
- # Build the collection of parameters
42
- def build_collection_param(params, format)
43
- params
44
- end
45
-
46
- # Make a request to an API endpoint with the given options
47
- #
48
- # @param http_method [Symbol] the HTTP method to be used
49
- # @param path [String] the path request will be made to
50
- # @param opts [Hash] any additional options needed
51
- # @return [Array<(Object, Fixnum, Hash)>] the deserialized body, status
52
- # code, and headers.
53
- def call_api(http_method, path, opts = {})
54
- query_params = opts.fetch(:query_params, {})
55
- header_params = opts.fetch(:header_params, {})
56
- form_params = opts.fetch(:form_params, {})
57
- add_auth(query_params, header_params, opts.fetch(:auth_names, []))
58
-
59
- uri = build_request_uri(path, query_params)
60
- request = Net::HTTP.const_get(http_method.capitalize).new(uri)
61
-
62
- add_form_params(request, form_params)
63
- add_header_params(request, header_params)
64
- request.body = opts[:body] if opts[:body]
65
- request.content_type = request['Content-Type'] if request['Content-Type']
66
-
67
- if @config.debugging
68
- @config.logger.debug("Request Body:\n#{request.body}\n")
69
- end
70
-
71
- response = @http.request(request)
72
- @cookie = cookie_from_response(response)
73
- api_key_from_response(response)
74
-
75
- return_type = opts.fetch(:return_type, {}).fetch(response.code, nil)
76
- data = deserialize(response, return_type)
77
- [data, Integer(response.code), response.each_header.to_h]
78
- end
79
-
80
- # Takes an object and returns the object as an HTTP body
81
- #
82
- # @param object [Object] object to transform
83
- # @return [String] object as JSON string
84
- def object_to_http_body(object)
85
- return object.map { |o| object_to_http_body(o) } if object.is_a?(Array)
86
-
87
- return object unless object.respond_to?(:to_hash)
88
-
89
- object.to_hash.to_json
90
- end
91
-
92
- # Select an Accept header to use
93
- #
94
- # @param types [Array] a list of suggested types
95
- # @return [String] the Accept header value
96
- def select_header_accept(types)
97
- return DEFAULT_MIME_TYPE unless types.is_a?(Array)
98
-
99
- types.find { |t| t.include?('json') } || types.join(', ')
100
- end
101
-
102
- # Select an Content-Type header to use
103
- #
104
- # @param types [Array] a list of suggested types
105
- # @return [String] the Content-Type header value
106
- def select_header_content_type(types)
107
- return DEFAULT_MIME_TYPE unless types.is_a?(Array)
108
-
109
- types.find { |t| t.include?('json') } || types.first
110
- end
111
-
112
- private
113
-
114
- def add_auth(query_params, header_params, auth_names)
115
- auth_names.map do |name|
116
- settings = @config.auth_settings.fetch(name, {})
117
- case settings[:in]
118
- when 'header'
119
- header_params[settings[:key]] = settings[:value]
120
- api_key_from_cookie(settings) unless settings[:value]
121
- when 'query'
122
- query_params[settings[:key]] = settings[:value]
123
- end
124
- end
125
- end
126
-
127
- def add_form_params(request, form_params)
128
- request.set_form_data(form_params) unless form_params.empty?
129
- end
130
-
131
- def add_header_params(request, headers)
132
- header_params = @default_headers.merge(headers)
133
- header_params.merge!(Hash(@cookie))
134
- header_params.map { |name, value| request[name] = value }
135
- end
136
-
137
- def add_query_params(uri, query_params)
138
- uri.query = URI.encode_www_form(query_params)
139
- end
140
-
141
- def build_request_uri(path = '', query_params = {})
142
- path = "/#{path}".gsub(%r{/+}, '/')
143
- uri = URI.parse(@config.base_url + path)
144
- add_query_params(uri, query_params)
145
- forced_query_params = path.split('?')[1]
146
- return URI.join(uri, '?' + forced_query_params) if forced_query_params
147
-
148
- uri
149
- end
150
-
151
- def create_http
152
- uri = build_request_uri
153
- http = Net::HTTP.new(uri.host, uri.port)
154
- http.use_ssl = @config.scheme == 'https'
155
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @config.verify_ssl_host
156
- http.read_timeout = @config.timeout
157
- http
158
- end
159
-
160
- # The default user agent
161
- #
162
- # @return [String] the default user agent
163
- def default_user_agent
164
- "SDK/#{VSphereAutomation::Runtime::VERSION} "\
165
- "Ruby/#{RUBY_VERSION} "\
166
- "(#{Gem::Platform.local.os}; "\
167
- "#{Gem::Platform.local.version}; "\
168
- "#{Gem::Platform.local.cpu})"
169
- end
170
-
171
- # Deserialize the response to the given return type
172
- #
173
- # @param [Response] response the HTTP response
174
- # @param [String] return_type the type to return
175
- # @return [Object] the response represented as the return type
176
- def deserialize(response, return_type)
177
- body = response.body
178
-
179
- return nil if body.nil? || body.empty? || return_type.nil?
180
-
181
- begin
182
- data = JSON.parse("[#{body}]", symbolize_names: true).first
183
- rescue JSON::ParserError => e
184
- raise e unless %w[String Date DateTime].include?(return_type)
185
-
186
- data = body
187
- end
188
-
189
- convert_to_type(data, return_type)
190
- end
191
-
192
- def convert_to_type(data, return_type)
193
- return nil if data.nil?
194
- case return_type
195
- when 'String'
196
- data.to_s
197
- when 'Integer'
198
- data.to_i
199
- when 'Float'
200
- data.to_f
201
- when 'BOOLEAN'
202
- data == true
203
- when 'DateTime'
204
- # parse date time (expecting ISO 8601 format)
205
- DateTime.parse data
206
- when 'Date'
207
- # parse date time (expecting ISO 8601 format)
208
- Date.parse data
209
- when 'Object'
210
- # generic object (usually a Hash), return directly
211
- data
212
- when /\AArray<(.+)>\z/
213
- # e.g. Array<Pet>
214
- sub_type = $1
215
- data.map { |item| convert_to_type(item, sub_type) }
216
- when /\AHash\<String, (.+)\>\z/
217
- # e.g. Hash<String, Integer>
218
- sub_type = $1
219
- {}.tap do |hash|
220
- data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
221
- end
222
- else
223
- # models, e.g. Pet
224
- VSphereAutomation.const_get(return_type).new.tap do |model|
225
- model.build_from_hash data
226
- end
227
- end
228
- end
229
-
230
- # Create the Cookie header from a response
231
- #
232
- # @param response [Net::HTTPResponse] the response
233
- # @return [Hash, nil] the Cookie header
234
- def cookie_from_response(response)
235
- { 'Cookie' => response['set-cookie'] } if response['set-cookie']
236
- end
237
-
238
- def api_key_from_response(response)
239
- key = @config.auth_settings['api_key'][:key]
240
- @config.api_key[key] = response[key] if response[key]
241
- end
242
-
243
- def api_key_from_cookie(auth)
244
- return if @cookie.nil?
245
-
246
- regex = /(?<key>#{auth[:key]})=(?<value>\w+)/
247
- matches = Hash(@cookie)['Cookie'].match(regex)
248
- key = @config.auth_settings['api_key'][:key]
249
- @config.api_key[key] = matches[:value] if matches
250
- end
251
-
252
- # An instance of the object in it's default state
253
- DEFAULT = new
254
-
255
- # The default MIME type for Content-Type and Accept headers
256
- DEFAULT_MIME_TYPE = 'application/json'
257
-
258
- private_constant :DEFAULT, :DEFAULT_MIME_TYPE
259
- end
260
- 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
- # cis - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
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
- # cis - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
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 = nil
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