harbor2_client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/README.md +186 -0
- data/Rakefile +8 -0
- data/docs/AdditionLink.md +9 -0
- data/docs/AdditionLinks.md +7 -0
- data/docs/Annotations.md +7 -0
- data/docs/Artifact.md +25 -0
- data/docs/ArtifactApi.md +694 -0
- data/docs/AuditLog.md +13 -0
- data/docs/AuditlogApi.md +69 -0
- data/docs/CVEAllowlist.md +13 -0
- data/docs/CVEAllowlistItem.md +8 -0
- data/docs/Error.md +9 -0
- data/docs/Errors.md +8 -0
- data/docs/Execution.md +17 -0
- data/docs/ExtraAttrs.md +7 -0
- data/docs/Icon.md +9 -0
- data/docs/IconApi.md +66 -0
- data/docs/Instance.md +19 -0
- data/docs/Label.md +15 -0
- data/docs/Metadata.md +13 -0
- data/docs/Metrics.md +14 -0
- data/docs/NativeReportSummary.md +15 -0
- data/docs/Platform.md +12 -0
- data/docs/PreheatApi.md +1176 -0
- data/docs/PreheatPolicy.md +18 -0
- data/docs/Project.md +22 -0
- data/docs/ProjectApi.md +542 -0
- data/docs/ProjectDeletable.md +9 -0
- data/docs/ProjectMetadata.md +14 -0
- data/docs/ProjectReq.md +13 -0
- data/docs/ProjectSummary.md +16 -0
- data/docs/ProjectSummaryQuota.md +9 -0
- data/docs/ProviderUnderProject.md +11 -0
- data/docs/Reference.md +13 -0
- data/docs/Registry.md +17 -0
- data/docs/RegistryCredential.md +10 -0
- data/docs/Repository.md +15 -0
- data/docs/RepositoryApi.md +256 -0
- data/docs/ResourceList.md +7 -0
- data/docs/ScanApi.md +138 -0
- data/docs/ScanOverview.md +7 -0
- data/docs/Tag.md +15 -0
- data/docs/Task.md +17 -0
- data/docs/VulnerabilitySummary.md +10 -0
- data/git_push.sh +55 -0
- data/harbor2_client.gemspec +46 -0
- data/lib/harbor2_client.rb +81 -0
- data/lib/harbor2_client/api/artifact_api.rb +848 -0
- data/lib/harbor2_client/api/auditlog_api.rb +91 -0
- data/lib/harbor2_client/api/icon_api.rb +84 -0
- data/lib/harbor2_client/api/preheat_api.rb +1327 -0
- data/lib/harbor2_client/api/project_api.rb +601 -0
- data/lib/harbor2_client/api/repository_api.rb +302 -0
- data/lib/harbor2_client/api/scan_api.rb +174 -0
- data/lib/harbor2_client/api_client.rb +391 -0
- data/lib/harbor2_client/api_error.rb +38 -0
- data/lib/harbor2_client/configuration.rb +209 -0
- data/lib/harbor2_client/models/addition_link.rb +195 -0
- data/lib/harbor2_client/models/addition_links.rb +175 -0
- data/lib/harbor2_client/models/annotations.rb +175 -0
- data/lib/harbor2_client/models/artifact.rb +355 -0
- data/lib/harbor2_client/models/audit_log.rb +235 -0
- data/lib/harbor2_client/models/cve_allowlist.rb +237 -0
- data/lib/harbor2_client/models/cve_allowlist_item.rb +186 -0
- data/lib/harbor2_client/models/error.rb +196 -0
- data/lib/harbor2_client/models/errors.rb +187 -0
- data/lib/harbor2_client/models/execution.rb +273 -0
- data/lib/harbor2_client/models/extra_attrs.rb +175 -0
- data/lib/harbor2_client/models/icon.rb +195 -0
- data/lib/harbor2_client/models/instance.rb +297 -0
- data/lib/harbor2_client/models/label.rb +255 -0
- data/lib/harbor2_client/models/metadata.rb +237 -0
- data/lib/harbor2_client/models/metrics.rb +245 -0
- data/lib/harbor2_client/models/native_report_summary.rb +255 -0
- data/lib/harbor2_client/models/platform.rb +227 -0
- data/lib/harbor2_client/models/preheat_policy.rb +285 -0
- data/lib/harbor2_client/models/project.rb +327 -0
- data/lib/harbor2_client/models/project_deletable.rb +195 -0
- data/lib/harbor2_client/models/project_metadata.rb +245 -0
- data/lib/harbor2_client/models/project_req.rb +235 -0
- data/lib/harbor2_client/models/project_summary.rb +263 -0
- data/lib/harbor2_client/models/project_summary_quota.rb +195 -0
- data/lib/harbor2_client/models/provider_under_project.rb +211 -0
- data/lib/harbor2_client/models/reference.rb +235 -0
- data/lib/harbor2_client/models/registry.rb +274 -0
- data/lib/harbor2_client/models/registry_credential.rb +205 -0
- data/lib/harbor2_client/models/repository.rb +255 -0
- data/lib/harbor2_client/models/resource_list.rb +175 -0
- data/lib/harbor2_client/models/scan_overview.rb +176 -0
- data/lib/harbor2_client/models/tag.rb +255 -0
- data/lib/harbor2_client/models/task.rb +274 -0
- data/lib/harbor2_client/models/vulnerability_summary.rb +208 -0
- data/lib/harbor2_client/version.rb +15 -0
- data/spec/api/artifact_api_spec.rb +209 -0
- data/spec/api/auditlog_api_spec.rb +50 -0
- data/spec/api/icon_api_spec.rb +48 -0
- data/spec/api/preheat_api_spec.rb +311 -0
- data/spec/api/project_api_spec.rb +160 -0
- data/spec/api/repository_api_spec.rb +94 -0
- data/spec/api/scan_api_spec.rb +66 -0
- data/spec/api_client_spec.rb +243 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/addition_link_spec.rb +47 -0
- data/spec/models/addition_links_spec.rb +35 -0
- data/spec/models/annotations_spec.rb +35 -0
- data/spec/models/artifact_spec.rb +143 -0
- data/spec/models/audit_log_spec.rb +71 -0
- data/spec/models/cve_allowlist_item_spec.rb +41 -0
- data/spec/models/cve_allowlist_spec.rb +71 -0
- data/spec/models/error_spec.rb +47 -0
- data/spec/models/errors_spec.rb +41 -0
- data/spec/models/execution_spec.rb +95 -0
- data/spec/models/extra_attrs_spec.rb +35 -0
- data/spec/models/icon_spec.rb +47 -0
- data/spec/models/instance_spec.rb +107 -0
- data/spec/models/label_spec.rb +83 -0
- data/spec/models/metadata_spec.rb +71 -0
- data/spec/models/metrics_spec.rb +77 -0
- data/spec/models/native_report_summary_spec.rb +83 -0
- data/spec/models/platform_spec.rb +65 -0
- data/spec/models/preheat_policy_spec.rb +101 -0
- data/spec/models/project_deletable_spec.rb +47 -0
- data/spec/models/project_metadata_spec.rb +77 -0
- data/spec/models/project_req_spec.rb +71 -0
- data/spec/models/project_spec.rb +125 -0
- data/spec/models/project_summary_quota_spec.rb +47 -0
- data/spec/models/project_summary_spec.rb +89 -0
- data/spec/models/provider_under_project_spec.rb +59 -0
- data/spec/models/reference_spec.rb +71 -0
- data/spec/models/registry_credential_spec.rb +53 -0
- data/spec/models/registry_spec.rb +95 -0
- data/spec/models/repository_spec.rb +83 -0
- data/spec/models/resource_list_spec.rb +35 -0
- data/spec/models/scan_overview_spec.rb +35 -0
- data/spec/models/tag_spec.rb +83 -0
- data/spec/models/task_spec.rb +95 -0
- data/spec/models/vulnerability_summary_spec.rb +53 -0
- data/spec/spec_helper.rb +111 -0
- metadata +428 -0
@@ -0,0 +1,187 @@
|
|
1
|
+
=begin
|
2
|
+
#Harbor API
|
3
|
+
|
4
|
+
#These APIs provide services for manipulating Harbor project.
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.17
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Harbor2Client
|
16
|
+
# The error array that describe the errors got during the handling of request
|
17
|
+
class Errors
|
18
|
+
attr_accessor :errors
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'errors' => :'errors'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Attribute type mapping.
|
28
|
+
def self.swagger_types
|
29
|
+
{
|
30
|
+
:'errors' => :'Array<Error>'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Initializes the object
|
35
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
36
|
+
def initialize(attributes = {})
|
37
|
+
return unless attributes.is_a?(Hash)
|
38
|
+
|
39
|
+
# convert string to symbol for hash key
|
40
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
41
|
+
|
42
|
+
if attributes.has_key?(:'errors')
|
43
|
+
if (value = attributes[:'errors']).is_a?(Array)
|
44
|
+
self.errors = value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
50
|
+
# @return Array for valid properties with the reasons
|
51
|
+
def list_invalid_properties
|
52
|
+
invalid_properties = Array.new
|
53
|
+
invalid_properties
|
54
|
+
end
|
55
|
+
|
56
|
+
# Check to see if the all the properties in the model are valid
|
57
|
+
# @return true if the model is valid
|
58
|
+
def valid?
|
59
|
+
true
|
60
|
+
end
|
61
|
+
|
62
|
+
# Checks equality by comparing each attribute.
|
63
|
+
# @param [Object] Object to be compared
|
64
|
+
def ==(o)
|
65
|
+
return true if self.equal?(o)
|
66
|
+
self.class == o.class &&
|
67
|
+
errors == o.errors
|
68
|
+
end
|
69
|
+
|
70
|
+
# @see the `==` method
|
71
|
+
# @param [Object] Object to be compared
|
72
|
+
def eql?(o)
|
73
|
+
self == o
|
74
|
+
end
|
75
|
+
|
76
|
+
# Calculates hash code according to all attributes.
|
77
|
+
# @return [Fixnum] Hash code
|
78
|
+
def hash
|
79
|
+
[errors].hash
|
80
|
+
end
|
81
|
+
|
82
|
+
# Builds the object from hash
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
84
|
+
# @return [Object] Returns the model itself
|
85
|
+
def build_from_hash(attributes)
|
86
|
+
return nil unless attributes.is_a?(Hash)
|
87
|
+
self.class.swagger_types.each_pair do |key, type|
|
88
|
+
if type =~ /\AArray<(.*)>/i
|
89
|
+
# check to ensure the input is an array given that the attribute
|
90
|
+
# is documented as an array but the input is not
|
91
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
92
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
93
|
+
end
|
94
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
95
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
96
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
97
|
+
end
|
98
|
+
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
102
|
+
# Deserializes the data based on type
|
103
|
+
# @param string type Data type
|
104
|
+
# @param string value Value to be deserialized
|
105
|
+
# @return [Object] Deserialized data
|
106
|
+
def _deserialize(type, value)
|
107
|
+
case type.to_sym
|
108
|
+
when :DateTime
|
109
|
+
DateTime.parse(value)
|
110
|
+
when :Date
|
111
|
+
Date.parse(value)
|
112
|
+
when :String
|
113
|
+
value.to_s
|
114
|
+
when :Integer
|
115
|
+
value.to_i
|
116
|
+
when :Float
|
117
|
+
value.to_f
|
118
|
+
when :BOOLEAN
|
119
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
120
|
+
true
|
121
|
+
else
|
122
|
+
false
|
123
|
+
end
|
124
|
+
when :Object
|
125
|
+
# generic object (usually a Hash), return directly
|
126
|
+
value
|
127
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
128
|
+
inner_type = Regexp.last_match[:inner_type]
|
129
|
+
value.map { |v| _deserialize(inner_type, v) }
|
130
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
131
|
+
k_type = Regexp.last_match[:k_type]
|
132
|
+
v_type = Regexp.last_match[:v_type]
|
133
|
+
{}.tap do |hash|
|
134
|
+
value.each do |k, v|
|
135
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
else # model
|
139
|
+
temp_model = Harbor2Client.const_get(type).new
|
140
|
+
temp_model.build_from_hash(value)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# Returns the string representation of the object
|
145
|
+
# @return [String] String presentation of the object
|
146
|
+
def to_s
|
147
|
+
to_hash.to_s
|
148
|
+
end
|
149
|
+
|
150
|
+
# to_body is an alias to to_hash (backward compatibility)
|
151
|
+
# @return [Hash] Returns the object in the form of hash
|
152
|
+
def to_body
|
153
|
+
to_hash
|
154
|
+
end
|
155
|
+
|
156
|
+
# Returns the object in the form of hash
|
157
|
+
# @return [Hash] Returns the object in the form of hash
|
158
|
+
def to_hash
|
159
|
+
hash = {}
|
160
|
+
self.class.attribute_map.each_pair do |attr, param|
|
161
|
+
value = self.send(attr)
|
162
|
+
next if value.nil?
|
163
|
+
hash[param] = _to_hash(value)
|
164
|
+
end
|
165
|
+
hash
|
166
|
+
end
|
167
|
+
|
168
|
+
# Outputs non-array value in the form of hash
|
169
|
+
# For object, use to_hash. Otherwise, just return the value
|
170
|
+
# @param [Object] value Any valid value
|
171
|
+
# @return [Hash] Returns the value in the form of hash
|
172
|
+
def _to_hash(value)
|
173
|
+
if value.is_a?(Array)
|
174
|
+
value.compact.map { |v| _to_hash(v) }
|
175
|
+
elsif value.is_a?(Hash)
|
176
|
+
{}.tap do |hash|
|
177
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
178
|
+
end
|
179
|
+
elsif value.respond_to? :to_hash
|
180
|
+
value.to_hash
|
181
|
+
else
|
182
|
+
value
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,273 @@
|
|
1
|
+
=begin
|
2
|
+
#Harbor API
|
3
|
+
|
4
|
+
#These APIs provide services for manipulating Harbor project.
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.17
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Harbor2Client
|
16
|
+
class Execution
|
17
|
+
# The ID of execution
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
# The vendor type of execution
|
21
|
+
attr_accessor :vendor_type
|
22
|
+
|
23
|
+
# The vendor id of execution
|
24
|
+
attr_accessor :vendor_id
|
25
|
+
|
26
|
+
# The status of execution
|
27
|
+
attr_accessor :status
|
28
|
+
|
29
|
+
# The status message of execution
|
30
|
+
attr_accessor :status_message
|
31
|
+
|
32
|
+
attr_accessor :metrics
|
33
|
+
|
34
|
+
# The trigger of execution
|
35
|
+
attr_accessor :trigger
|
36
|
+
|
37
|
+
attr_accessor :extra_attrs
|
38
|
+
|
39
|
+
# The start time of execution
|
40
|
+
attr_accessor :start_time
|
41
|
+
|
42
|
+
# The end time of execution
|
43
|
+
attr_accessor :end_time
|
44
|
+
|
45
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
46
|
+
def self.attribute_map
|
47
|
+
{
|
48
|
+
:'id' => :'id',
|
49
|
+
:'vendor_type' => :'vendor_type',
|
50
|
+
:'vendor_id' => :'vendor_id',
|
51
|
+
:'status' => :'status',
|
52
|
+
:'status_message' => :'status_message',
|
53
|
+
:'metrics' => :'metrics',
|
54
|
+
:'trigger' => :'trigger',
|
55
|
+
:'extra_attrs' => :'extra_attrs',
|
56
|
+
:'start_time' => :'start_time',
|
57
|
+
:'end_time' => :'end_time'
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# Attribute type mapping.
|
62
|
+
def self.swagger_types
|
63
|
+
{
|
64
|
+
:'id' => :'Integer',
|
65
|
+
:'vendor_type' => :'String',
|
66
|
+
:'vendor_id' => :'Integer',
|
67
|
+
:'status' => :'String',
|
68
|
+
:'status_message' => :'String',
|
69
|
+
:'metrics' => :'Metrics',
|
70
|
+
:'trigger' => :'String',
|
71
|
+
:'extra_attrs' => :'ExtraAttrs',
|
72
|
+
:'start_time' => :'String',
|
73
|
+
:'end_time' => :'String'
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
# Initializes the object
|
78
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
79
|
+
def initialize(attributes = {})
|
80
|
+
return unless attributes.is_a?(Hash)
|
81
|
+
|
82
|
+
# convert string to symbol for hash key
|
83
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
84
|
+
|
85
|
+
if attributes.has_key?(:'id')
|
86
|
+
self.id = attributes[:'id']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.has_key?(:'vendor_type')
|
90
|
+
self.vendor_type = attributes[:'vendor_type']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.has_key?(:'vendor_id')
|
94
|
+
self.vendor_id = attributes[:'vendor_id']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.has_key?(:'status')
|
98
|
+
self.status = attributes[:'status']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.has_key?(:'status_message')
|
102
|
+
self.status_message = attributes[:'status_message']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.has_key?(:'metrics')
|
106
|
+
self.metrics = attributes[:'metrics']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.has_key?(:'trigger')
|
110
|
+
self.trigger = attributes[:'trigger']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.has_key?(:'extra_attrs')
|
114
|
+
self.extra_attrs = attributes[:'extra_attrs']
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.has_key?(:'start_time')
|
118
|
+
self.start_time = attributes[:'start_time']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.has_key?(:'end_time')
|
122
|
+
self.end_time = attributes[:'end_time']
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
127
|
+
# @return Array for valid properties with the reasons
|
128
|
+
def list_invalid_properties
|
129
|
+
invalid_properties = Array.new
|
130
|
+
invalid_properties
|
131
|
+
end
|
132
|
+
|
133
|
+
# Check to see if the all the properties in the model are valid
|
134
|
+
# @return true if the model is valid
|
135
|
+
def valid?
|
136
|
+
true
|
137
|
+
end
|
138
|
+
|
139
|
+
# Checks equality by comparing each attribute.
|
140
|
+
# @param [Object] Object to be compared
|
141
|
+
def ==(o)
|
142
|
+
return true if self.equal?(o)
|
143
|
+
self.class == o.class &&
|
144
|
+
id == o.id &&
|
145
|
+
vendor_type == o.vendor_type &&
|
146
|
+
vendor_id == o.vendor_id &&
|
147
|
+
status == o.status &&
|
148
|
+
status_message == o.status_message &&
|
149
|
+
metrics == o.metrics &&
|
150
|
+
trigger == o.trigger &&
|
151
|
+
extra_attrs == o.extra_attrs &&
|
152
|
+
start_time == o.start_time &&
|
153
|
+
end_time == o.end_time
|
154
|
+
end
|
155
|
+
|
156
|
+
# @see the `==` method
|
157
|
+
# @param [Object] Object to be compared
|
158
|
+
def eql?(o)
|
159
|
+
self == o
|
160
|
+
end
|
161
|
+
|
162
|
+
# Calculates hash code according to all attributes.
|
163
|
+
# @return [Fixnum] Hash code
|
164
|
+
def hash
|
165
|
+
[id, vendor_type, vendor_id, status, status_message, metrics, trigger, extra_attrs, start_time, end_time].hash
|
166
|
+
end
|
167
|
+
|
168
|
+
# Builds the object from hash
|
169
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
170
|
+
# @return [Object] Returns the model itself
|
171
|
+
def build_from_hash(attributes)
|
172
|
+
return nil unless attributes.is_a?(Hash)
|
173
|
+
self.class.swagger_types.each_pair do |key, type|
|
174
|
+
if type =~ /\AArray<(.*)>/i
|
175
|
+
# check to ensure the input is an array given that the attribute
|
176
|
+
# is documented as an array but the input is not
|
177
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
178
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
179
|
+
end
|
180
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
181
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
182
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
183
|
+
end
|
184
|
+
|
185
|
+
self
|
186
|
+
end
|
187
|
+
|
188
|
+
# Deserializes the data based on type
|
189
|
+
# @param string type Data type
|
190
|
+
# @param string value Value to be deserialized
|
191
|
+
# @return [Object] Deserialized data
|
192
|
+
def _deserialize(type, value)
|
193
|
+
case type.to_sym
|
194
|
+
when :DateTime
|
195
|
+
DateTime.parse(value)
|
196
|
+
when :Date
|
197
|
+
Date.parse(value)
|
198
|
+
when :String
|
199
|
+
value.to_s
|
200
|
+
when :Integer
|
201
|
+
value.to_i
|
202
|
+
when :Float
|
203
|
+
value.to_f
|
204
|
+
when :BOOLEAN
|
205
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
206
|
+
true
|
207
|
+
else
|
208
|
+
false
|
209
|
+
end
|
210
|
+
when :Object
|
211
|
+
# generic object (usually a Hash), return directly
|
212
|
+
value
|
213
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
214
|
+
inner_type = Regexp.last_match[:inner_type]
|
215
|
+
value.map { |v| _deserialize(inner_type, v) }
|
216
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
217
|
+
k_type = Regexp.last_match[:k_type]
|
218
|
+
v_type = Regexp.last_match[:v_type]
|
219
|
+
{}.tap do |hash|
|
220
|
+
value.each do |k, v|
|
221
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
else # model
|
225
|
+
temp_model = Harbor2Client.const_get(type).new
|
226
|
+
temp_model.build_from_hash(value)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# Returns the string representation of the object
|
231
|
+
# @return [String] String presentation of the object
|
232
|
+
def to_s
|
233
|
+
to_hash.to_s
|
234
|
+
end
|
235
|
+
|
236
|
+
# to_body is an alias to to_hash (backward compatibility)
|
237
|
+
# @return [Hash] Returns the object in the form of hash
|
238
|
+
def to_body
|
239
|
+
to_hash
|
240
|
+
end
|
241
|
+
|
242
|
+
# Returns the object in the form of hash
|
243
|
+
# @return [Hash] Returns the object in the form of hash
|
244
|
+
def to_hash
|
245
|
+
hash = {}
|
246
|
+
self.class.attribute_map.each_pair do |attr, param|
|
247
|
+
value = self.send(attr)
|
248
|
+
next if value.nil?
|
249
|
+
hash[param] = _to_hash(value)
|
250
|
+
end
|
251
|
+
hash
|
252
|
+
end
|
253
|
+
|
254
|
+
# Outputs non-array value in the form of hash
|
255
|
+
# For object, use to_hash. Otherwise, just return the value
|
256
|
+
# @param [Object] value Any valid value
|
257
|
+
# @return [Hash] Returns the value in the form of hash
|
258
|
+
def _to_hash(value)
|
259
|
+
if value.is_a?(Array)
|
260
|
+
value.compact.map { |v| _to_hash(v) }
|
261
|
+
elsif value.is_a?(Hash)
|
262
|
+
{}.tap do |hash|
|
263
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
264
|
+
end
|
265
|
+
elsif value.respond_to? :to_hash
|
266
|
+
value.to_hash
|
267
|
+
else
|
268
|
+
value
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
end
|