harbor2_client 0.1.0

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