intersight_client 0.1.3 → 0.1.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.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intersight_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - XLAB
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-09 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -57,18 +57,9 @@ extensions: []
57
57
  extra_rdoc_files: []
58
58
  files:
59
59
  - Gemfile
60
- - Gemfile.lock
61
60
  - LICENSE
62
61
  - README.md
63
62
  - Rakefile
64
- - bin/console
65
- - bin/oas_generator/patch-auth.diff
66
- - bin/oas_generator/regex-syntax-fix.sh
67
- - bin/oas_generator/reorder-requires.sh
68
- - bin/oas_generator/replace-discriminator-names.sh
69
- - bin/oas_generator/templates/base_object.mustache
70
- - bin/oas_generator/templates/partial_model_generic.mustache
71
- - bin/setup
72
63
  - docs/AaaAbstractAuditRecord.md
73
64
  - docs/AaaAbstractAuditRecordAllOf.md
74
65
  - docs/AaaApi.md
@@ -5994,10 +5985,6 @@ files:
5994
5985
  - docs/WorkflowXmlApi.md
5995
5986
  - docs/X509Certificate.md
5996
5987
  - docs/X509CertificateAllOf.md
5997
- - git_push.sh
5998
- - intersight-openapi-v3-1.0.9.4870.yaml
5999
- - intersight_client-0.1.2.gem
6000
- - intersight_client.gemspec
6001
5988
  - lib/intersight_client.rb
6002
5989
  - lib/intersight_client/api/aaa_api.rb
6003
5990
  - lib/intersight_client/api/access_api.rb
data/Gemfile.lock DELETED
@@ -1,68 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- intersight_client (0.1.3)
5
- typhoeus (~> 1.0, >= 1.0.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.2)
11
- byebug (11.1.3)
12
- coderay (1.1.3)
13
- diff-lcs (1.5.0)
14
- ethon (0.15.0)
15
- ffi (>= 1.15.0)
16
- ffi (1.15.5)
17
- jaro_winkler (1.5.4)
18
- method_source (1.0.0)
19
- parallel (1.21.0)
20
- parser (3.1.0.0)
21
- ast (~> 2.4.1)
22
- pry (0.13.1)
23
- coderay (~> 1.1)
24
- method_source (~> 1.0)
25
- pry-byebug (3.9.0)
26
- byebug (~> 11.0)
27
- pry (~> 0.13.0)
28
- psych (4.0.2)
29
- rainbow (3.1.1)
30
- rake (13.0.6)
31
- rspec (3.10.0)
32
- rspec-core (~> 3.10.0)
33
- rspec-expectations (~> 3.10.0)
34
- rspec-mocks (~> 3.10.0)
35
- rspec-core (3.10.1)
36
- rspec-support (~> 3.10.0)
37
- rspec-expectations (3.10.2)
38
- diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.10.0)
40
- rspec-mocks (3.10.2)
41
- diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.10.0)
43
- rspec-support (3.10.3)
44
- rubocop (0.66.0)
45
- jaro_winkler (~> 1.5.1)
46
- parallel (~> 1.10)
47
- parser (>= 2.5, != 2.5.1.1)
48
- psych (>= 3.1.0)
49
- rainbow (>= 2.2.2, < 4.0)
50
- ruby-progressbar (~> 1.7)
51
- unicode-display_width (>= 1.4.0, < 1.6)
52
- ruby-progressbar (1.11.0)
53
- typhoeus (1.4.0)
54
- ethon (>= 0.9.0)
55
- unicode-display_width (1.5.0)
56
-
57
- PLATFORMS
58
- x86_64-linux
59
-
60
- DEPENDENCIES
61
- intersight_client!
62
- pry-byebug
63
- rake (~> 13.0.1)
64
- rspec (~> 3.6, >= 3.6.0)
65
- rubocop (~> 0.66.0)
66
-
67
- BUNDLED WITH
68
- 2.2.31
data/bin/console DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "intersight_client"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- require "pry"
10
- Pry.start
@@ -1,207 +0,0 @@
1
- diff --git a/lib/intersight_client/api_client.rb b/lib/intersight_client/api_client.rb
2
- index 25233b33..81a5a659 100644
3
- --- a/lib/intersight_client/api_client.rb
4
- +++ b/lib/intersight_client/api_client.rb
5
- @@ -16,6 +16,10 @@ require 'logger'
6
- require 'tempfile'
7
- require 'time'
8
- require 'typhoeus'
9
- +require 'base64'
10
- +require 'digest'
11
- +require 'openssl'
12
- +require 'uri'
13
-
14
- module IntersightClient
15
- class ApiClient
16
- @@ -94,7 +98,7 @@ module IntersightClient
17
- query_params = opts[:query_params] || {}
18
- form_params = opts[:form_params] || {}
19
-
20
- - update_params_for_auth! header_params, query_params, opts[:auth_names]
21
- + # update_params_for_auth! header_params, query_params, opts[:auth_names]
22
-
23
- # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
24
- _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
25
- @@ -123,11 +127,82 @@ module IntersightClient
26
- end
27
- end
28
-
29
- + # Auth
30
- + # Typhoeus::Request called to build URI with parameters
31
- + target_uri = URI(Typhoeus::Request.new(url, req_opts).url)
32
- + auth_headers = {
33
- + "Host" => target_uri.host,
34
- + "Date" => Time.now.httpdate,
35
- + "Digest" => "SHA-256=" + Base64.encode64(get_sha256_digest(req_body)).gsub(/\n/, '')
36
- + }
37
- + path = target_uri.path
38
- + path = path + "?" + target_uri.query unless target_uri.query.nil?
39
- + request_target = http_method.to_s + " " + path
40
- + string_to_sign = prepare_str_to_sign(request_target, auth_headers)
41
- + auth_digest = get_sha256_digest(string_to_sign.encode('utf-8'))
42
- + b64_signed_msg = get_ecdsasig_b64encode(auth_digest)
43
- + header_params["Authorization"] = get_auth_header(auth_headers, b64_signed_msg)
44
- + req_opts[:headers].merge!(auth_headers)
45
- + if @config.debugging
46
- + @config.logger.debug "\nHTTP request headers:\n" + header_params.map{|k,v| "#{k}: #{v}"}.join("\n") + "\n"
47
- + end
48
- +
49
- request = Typhoeus::Request.new(url, req_opts)
50
- download_file(request) if opts[:return_type] == 'File'
51
- request
52
- end
53
-
54
- + # Auth helper methods
55
- + private
56
- +
57
- + # Generate SHA256 digest from data
58
- + def get_sha256_digest(data)
59
- + data = "" if data.nil?
60
- + digest = Digest::SHA2.new(256)
61
- + digest.update(data)
62
- + return digest.digest
63
- + end
64
- +
65
- + # Concatenates Intersight headers in preparation to be signed
66
- + def prepare_str_to_sign(request_target, auth_headers)
67
- + str = "(request-target): " + request_target + "\n"
68
- + i=0
69
- + auth_headers.each do |key, value|
70
- + str = str + key.to_s.downcase + ": " + value.to_s
71
- + if i< (auth_headers.length-1)
72
- + str = str + "\n"
73
- + end
74
- + i+=1
75
- + end
76
- + return str
77
- + end
78
- +
79
- + # Gets ECDSA signed and choped encoded base64 signature
80
- + def get_ecdsasig_b64encode(data)
81
- + signature = @config.api_key.dsa_sign_asn1(data)
82
- + encoded = Base64.encode64(signature)
83
- + # Remove new lines in the string
84
- + return encoded.gsub(/\n/, '')
85
- + end
86
- +
87
- + SIGNATURE_ALGORITHM = "hs2019"
88
- +
89
- + # Assembles an Intersight formatted authorization header
90
- + def get_auth_header(hdrs, signed_msg)
91
- + auth_str = ""
92
- + auth_str = auth_str + "Signature"
93
- + auth_str = auth_str + " " + "keyId=\"" + @config.api_key_id + "\"," + "algorithm=\"" + SIGNATURE_ALGORITHM + "\"," + "headers=\"(request-target)"
94
- + i=0
95
- + hdrs.each_key do |key|
96
- + auth_str = auth_str + " " + key.to_s.downcase
97
- + end
98
- + auth_str = auth_str + "\""
99
- + auth_str = auth_str + "," + "signature=\"" + signed_msg + "\""
100
- + return auth_str
101
- + end
102
- +
103
- + public
104
- +
105
- # Builds the HTTP request body
106
- #
107
- # @param [Hash] header_params Header parameters
108
- diff --git a/lib/intersight_client/configuration.rb b/lib/intersight_client/configuration.rb
109
- index e098aa60..2b5659ea 100644
110
- --- a/lib/intersight_client/configuration.rb
111
- +++ b/lib/intersight_client/configuration.rb
112
- @@ -33,21 +33,22 @@ module IntersightClient
113
- # Default server operation variables
114
- attr_accessor :server_operation_variables
115
-
116
- - # Defines API keys used with API Key authentications.
117
- + # Defines the API key used for authentication.
118
- #
119
- - # @return [Hash] key: parameter name, value: parameter value (API key)
120
- - #
121
- - # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
122
- - # config.api_key['api_key'] = 'xxx'
123
- - attr_accessor :api_key
124
- + # @return [OpenSSL::PKey::EC] private key
125
- + attr_reader :api_key
126
-
127
- - # Defines API key prefixes used with API Key authentications.
128
- + # Defines the API key used for authentication.
129
- #
130
- - # @return [Hash] key: parameter name, value: API key prefix
131
- + # @param api_key_str [String]: String value of the EC private key
132
- + def api_key= api_key_str
133
- + @api_key = OpenSSL::PKey::EC.new(api_key_str)
134
- + end
135
- +
136
- + # Defines the ID of the API key used for authentication.
137
- #
138
- - # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
139
- - # config.api_key_prefix['api_key'] = 'Token'
140
- - attr_accessor :api_key_prefix
141
- + # @return [String] key ID
142
- + attr_accessor :api_key_id
143
-
144
- # Defines the username used with HTTP basic authentication.
145
- #
146
- @@ -145,8 +146,8 @@ module IntersightClient
147
- @server_operation_index = {}
148
- @server_variables = {}
149
- @server_operation_variables = {}
150
- - @api_key = {}
151
- - @api_key_prefix = {}
152
- + @api_key = nil
153
- + @api_key_id = nil
154
- @client_side_validation = true
155
- @verify_ssl = true
156
- @verify_ssl_host = true
157
- @@ -195,50 +196,6 @@ module IntersightClient
158
- server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
159
- end
160
-
161
- - # Gets API key (with prefix if set).
162
- - # @param [String] param_name the parameter name of API key auth
163
- - def api_key_with_prefix(param_name, param_alias = nil)
164
- - key = @api_key[param_name]
165
- - key = @api_key.fetch(param_alias, key) unless param_alias.nil?
166
- - if @api_key_prefix[param_name]
167
- - "#{@api_key_prefix[param_name]} #{key}"
168
- - else
169
- - key
170
- - end
171
- - end
172
- -
173
- - # Gets Basic Auth token string
174
- - def basic_auth_token
175
- - 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
176
- - end
177
- -
178
- - # Returns Auth Settings hash for api client.
179
- - def auth_settings
180
- - {
181
- - 'cookieAuth' =>
182
- - {
183
- - type: 'api_key',
184
- - in: ,
185
- - key: 'X-Starship-Token',
186
- - value: api_key_with_prefix('cookieAuth')
187
- - },
188
- - 'oAuth2' =>
189
- - {
190
- - type: 'oauth2',
191
- - in: 'header',
192
- - key: 'Authorization',
193
- - value: "Bearer #{access_token}"
194
- - },
195
- - 'oAuth2' =>
196
- - {
197
- - type: 'oauth2',
198
- - in: 'header',
199
- - key: 'Authorization',
200
- - value: "Bearer #{access_token}"
201
- - },
202
- - }
203
- - end
204
- -
205
- # Returns an array of Server setting
206
- def server_settings
207
- [
@@ -1,5 +0,0 @@
1
- find . -name "*.rb" -exec sed -i -e '/Regexp.new/ s|\\\\/|\\/|g' {} +
2
- find . -name "*.rb" -exec sed -i -e 's|\\xFF|\\u00FF|g' {} +
3
- find . -name "*.rb" -exec sed -i -e 's|#\[\\\]|#\\\[\\\]|g' {} +
4
- find . -name "*.rb" -exec sed -i -e 's|a-zA-Z0-9-|a-zA-Z0-9\\-|g' {} +
5
-
@@ -1,47 +0,0 @@
1
- mv lib/intersight_client.rb lib/intersight_client.rb.old
2
-
3
- MODELS_LINE=$(grep -n "# Models" lib/intersight_client.rb.old | cut -d : -f 1)
4
- head -n $MODELS_LINE lib/intersight_client.rb.old > lib/intersight_client.rb
5
-
6
- grep -r "^ class " lib/intersight_client/models/ | grep -v '<' | cut -c 30- > /tmp/0-models
7
-
8
- N=0
9
- while true; do
10
- echo "Iteration ${N}"
11
- let M=$N+1
12
-
13
- if ! [ -s /tmp/${N}-models ]; then
14
- break
15
- fi
16
-
17
- rm /tmp/${M}-models 2>/dev/null
18
- touch /tmp/${M}-models
19
- while read ml; do
20
- # echo $ml
21
- cname=$(echo $ml | cut -d : -f 2 | cut -c 8- | cut -d " " -f 1)
22
- fname=$(echo $ml | cut -d : -f 1 | cut -d . -f 1)
23
- echo "require 'intersight_client/models/${fname}'" >> lib/intersight_client.rb
24
- grep -r "^ class " lib/intersight_client/models/ | grep " < ${cname}$" | cut -c 30- >> /tmp/${M}-models
25
- done < /tmp/${N}-models
26
-
27
- let N=$M
28
-
29
- done
30
-
31
- # files with class << self
32
- grep -r "class << self" lib/intersight_client/models/ | cut -d : -f 1 | cut -d . -f 1 | cut -c 5- | sed "s/^/require '/g" | sed "s/$/'/g" >> lib/intersight_client.rb
33
- echo "Done reordering requires for models"
34
-
35
- # output remaining lines in intersight_client.rb
36
- APIS_LINE=$(grep -n "# APIs" lib/intersight_client.rb.old | cut -d : -f 1)
37
- let APIS_LINE=$APIS_LINE-1
38
- tail -n +$APIS_LINE lib/intersight_client.rb.old >> lib/intersight_client.rb
39
-
40
- if [[ $(wc -l lib/intersight_client.rb | cut -d ' ' -f 1) == $(wc -l lib/intersight_client.rb.old | cut -d ' ' -f 1) ]]; then
41
- echo "Line count check OK"
42
- rm lib/intersight_client.rb.old
43
- else
44
- echo "Line count check failed!"
45
- exit 1
46
- fi
47
-
@@ -1,8 +0,0 @@
1
- find lib/intersight_client/models/ -name "*.rb" -exec sed -i '/def openapi_discriminator_name$/{n;s/object_type/ObjectType/}' {} +
2
-
3
- find lib/intersight_client/models/ -name "*.rb" -exec sed -i '/def self.openapi_discriminator_name$/{n;s/object_type/ObjectType/}' {} +
4
-
5
- find lib/intersight_client/models/ -name "*.rb" -exec sed -i '/def openapi_discriminator_name$/{n;s/class_id/ClassId/}' {} +
6
-
7
- find lib/intersight_client/models/ -name "*.rb" -exec sed -i '/def self.openapi_discriminator_name$/{n;s/class_id/ClassId/}' {} +
8
-
@@ -1,120 +0,0 @@
1
- # Builds the object from hash
2
- # @param [Hash] attributes Model attributes in the form of hash
3
- # @return [Object] Returns the model itself
4
- def self.build_from_hash(attributes)
5
- new.build_from_hash(attributes)
6
- end
7
-
8
- # Builds the object from hash
9
- # @param [Hash] attributes Model attributes in the form of hash
10
- # @return [Object] Returns the model itself
11
- def build_from_hash(attributes)
12
- return nil unless attributes.is_a?(Hash)
13
- {{#parent}}
14
- super(attributes)
15
- {{/parent}}
16
- {{classname}}.openapi_types.each_pair do |key, type|
17
- if attributes[{{classname}}.attribute_map[key]].nil? && {{classname}}.openapi_nullable.include?(key)
18
- self.send("#{key}=", nil)
19
- elsif type =~ /\AArray<(.*)>/i
20
- # check to ensure the input is an array given that the attribute
21
- # is documented as an array but the input is not
22
- if attributes[{{classname}}.attribute_map[key]].is_a?(Array)
23
- self.send("#{key}=", attributes[{{classname}}.attribute_map[key]].map { |v| _deserialize($1, v) })
24
- end
25
- elsif !attributes[{{classname}}.attribute_map[key]].nil?
26
- self.send("#{key}=", _deserialize(type, attributes[{{classname}}.attribute_map[key]]))
27
- end
28
- end
29
-
30
- self
31
- end
32
-
33
- # Deserializes the data based on type
34
- # @param string type Data type
35
- # @param string value Value to be deserialized
36
- # @return [Object] Deserialized data
37
- def _deserialize(type, value)
38
- case type.to_sym
39
- when :Time
40
- Time.parse(value)
41
- when :Date
42
- Date.parse(value)
43
- when :String
44
- value.to_s
45
- when :Integer
46
- value.to_i
47
- when :Float
48
- value.to_f
49
- when :Boolean
50
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
51
- true
52
- else
53
- false
54
- end
55
- when :Object
56
- # generic object (usually a Hash), return directly
57
- value
58
- when /\AArray<(?<inner_type>.+)>\z/
59
- inner_type = Regexp.last_match[:inner_type]
60
- value.map { |v| _deserialize(inner_type, v) }
61
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
62
- k_type = Regexp.last_match[:k_type]
63
- v_type = Regexp.last_match[:v_type]
64
- {}.tap do |hash|
65
- value.each do |k, v|
66
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
67
- end
68
- end
69
- else # model
70
- # models (e.g. Pet) or oneOf
71
- klass = {{moduleName}}.const_get(type)
72
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
73
- end
74
- end
75
-
76
- # Returns the string representation of the object
77
- # @return [String] String presentation of the object
78
- def to_s
79
- to_hash.to_s
80
- end
81
-
82
- # to_body is an alias to to_hash (backward compatibility)
83
- # @return [Hash] Returns the object in the form of hash
84
- def to_body
85
- to_hash
86
- end
87
-
88
- # Returns the object in the form of hash
89
- # @return [Hash] Returns the object in the form of hash
90
- def to_hash
91
- hash = {{^parent}}{}{{/parent}}{{#parent}}super{{/parent}}
92
- {{classname}}.attribute_map.each_pair do |attr, param|
93
- value = self.send(attr)
94
- if value.nil?
95
- is_nullable = {{classname}}.openapi_nullable.include?(attr)
96
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
97
- end
98
-
99
- hash[param] = _to_hash(value)
100
- end
101
- hash
102
- end
103
-
104
- # Outputs non-array value in the form of hash
105
- # For object, use to_hash. Otherwise, just return the value
106
- # @param [Object] value Any valid value
107
- # @return [Hash] Returns the value in the form of hash
108
- def _to_hash(value)
109
- if value.is_a?(Array)
110
- value.compact.map { |v| _to_hash(v) }
111
- elsif value.is_a?(Hash)
112
- {}.tap do |hash|
113
- value.each { |k, v| hash[k] = _to_hash(v) }
114
- end
115
- elsif value.respond_to? :to_hash
116
- value.to_hash
117
- else
118
- value
119
- end
120
- end