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,245 @@
|
|
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 ProjectMetadata
|
17
|
+
# The public status of the project. The valid values are \"true\", \"false\".
|
18
|
+
attr_accessor :public
|
19
|
+
|
20
|
+
# Whether content trust is enabled or not. If it is enabled, user can't pull unsigned images from this project. The valid values are \"true\", \"false\".
|
21
|
+
attr_accessor :enable_content_trust
|
22
|
+
|
23
|
+
# Whether prevent the vulnerable images from running. The valid values are \"true\", \"false\".
|
24
|
+
attr_accessor :prevent_vul
|
25
|
+
|
26
|
+
# If the vulnerability is high than severity defined here, the images can't be pulled. The valid values are \"none\", \"low\", \"medium\", \"high\", \"critical\".
|
27
|
+
attr_accessor :severity
|
28
|
+
|
29
|
+
# Whether scan images automatically when pushing. The valid values are \"true\", \"false\".
|
30
|
+
attr_accessor :auto_scan
|
31
|
+
|
32
|
+
# Whether this project reuse the system level CVE allowlist as the allowlist of its own. The valid values are \"true\", \"false\". If it is set to \"true\" the actual allowlist associate with this project, if any, will be ignored.
|
33
|
+
attr_accessor :reuse_sys_cve_allowlist
|
34
|
+
|
35
|
+
# The ID of the tag retention policy for the project
|
36
|
+
attr_accessor :retention_id
|
37
|
+
|
38
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
39
|
+
def self.attribute_map
|
40
|
+
{
|
41
|
+
:'public' => :'public',
|
42
|
+
:'enable_content_trust' => :'enable_content_trust',
|
43
|
+
:'prevent_vul' => :'prevent_vul',
|
44
|
+
:'severity' => :'severity',
|
45
|
+
:'auto_scan' => :'auto_scan',
|
46
|
+
:'reuse_sys_cve_allowlist' => :'reuse_sys_cve_allowlist',
|
47
|
+
:'retention_id' => :'retention_id'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute type mapping.
|
52
|
+
def self.swagger_types
|
53
|
+
{
|
54
|
+
:'public' => :'String',
|
55
|
+
:'enable_content_trust' => :'String',
|
56
|
+
:'prevent_vul' => :'String',
|
57
|
+
:'severity' => :'String',
|
58
|
+
:'auto_scan' => :'String',
|
59
|
+
:'reuse_sys_cve_allowlist' => :'String',
|
60
|
+
:'retention_id' => :'String'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# Initializes the object
|
65
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
66
|
+
def initialize(attributes = {})
|
67
|
+
return unless attributes.is_a?(Hash)
|
68
|
+
|
69
|
+
# convert string to symbol for hash key
|
70
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
71
|
+
|
72
|
+
if attributes.has_key?(:'public')
|
73
|
+
self.public = attributes[:'public']
|
74
|
+
end
|
75
|
+
|
76
|
+
if attributes.has_key?(:'enable_content_trust')
|
77
|
+
self.enable_content_trust = attributes[:'enable_content_trust']
|
78
|
+
end
|
79
|
+
|
80
|
+
if attributes.has_key?(:'prevent_vul')
|
81
|
+
self.prevent_vul = attributes[:'prevent_vul']
|
82
|
+
end
|
83
|
+
|
84
|
+
if attributes.has_key?(:'severity')
|
85
|
+
self.severity = attributes[:'severity']
|
86
|
+
end
|
87
|
+
|
88
|
+
if attributes.has_key?(:'auto_scan')
|
89
|
+
self.auto_scan = attributes[:'auto_scan']
|
90
|
+
end
|
91
|
+
|
92
|
+
if attributes.has_key?(:'reuse_sys_cve_allowlist')
|
93
|
+
self.reuse_sys_cve_allowlist = attributes[:'reuse_sys_cve_allowlist']
|
94
|
+
end
|
95
|
+
|
96
|
+
if attributes.has_key?(:'retention_id')
|
97
|
+
self.retention_id = attributes[:'retention_id']
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
102
|
+
# @return Array for valid properties with the reasons
|
103
|
+
def list_invalid_properties
|
104
|
+
invalid_properties = Array.new
|
105
|
+
invalid_properties
|
106
|
+
end
|
107
|
+
|
108
|
+
# Check to see if the all the properties in the model are valid
|
109
|
+
# @return true if the model is valid
|
110
|
+
def valid?
|
111
|
+
true
|
112
|
+
end
|
113
|
+
|
114
|
+
# Checks equality by comparing each attribute.
|
115
|
+
# @param [Object] Object to be compared
|
116
|
+
def ==(o)
|
117
|
+
return true if self.equal?(o)
|
118
|
+
self.class == o.class &&
|
119
|
+
public == o.public &&
|
120
|
+
enable_content_trust == o.enable_content_trust &&
|
121
|
+
prevent_vul == o.prevent_vul &&
|
122
|
+
severity == o.severity &&
|
123
|
+
auto_scan == o.auto_scan &&
|
124
|
+
reuse_sys_cve_allowlist == o.reuse_sys_cve_allowlist &&
|
125
|
+
retention_id == o.retention_id
|
126
|
+
end
|
127
|
+
|
128
|
+
# @see the `==` method
|
129
|
+
# @param [Object] Object to be compared
|
130
|
+
def eql?(o)
|
131
|
+
self == o
|
132
|
+
end
|
133
|
+
|
134
|
+
# Calculates hash code according to all attributes.
|
135
|
+
# @return [Fixnum] Hash code
|
136
|
+
def hash
|
137
|
+
[public, enable_content_trust, prevent_vul, severity, auto_scan, reuse_sys_cve_allowlist, retention_id].hash
|
138
|
+
end
|
139
|
+
|
140
|
+
# Builds the object from hash
|
141
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
142
|
+
# @return [Object] Returns the model itself
|
143
|
+
def build_from_hash(attributes)
|
144
|
+
return nil unless attributes.is_a?(Hash)
|
145
|
+
self.class.swagger_types.each_pair do |key, type|
|
146
|
+
if type =~ /\AArray<(.*)>/i
|
147
|
+
# check to ensure the input is an array given that the attribute
|
148
|
+
# is documented as an array but the input is not
|
149
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
150
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
151
|
+
end
|
152
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
153
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
154
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
155
|
+
end
|
156
|
+
|
157
|
+
self
|
158
|
+
end
|
159
|
+
|
160
|
+
# Deserializes the data based on type
|
161
|
+
# @param string type Data type
|
162
|
+
# @param string value Value to be deserialized
|
163
|
+
# @return [Object] Deserialized data
|
164
|
+
def _deserialize(type, value)
|
165
|
+
case type.to_sym
|
166
|
+
when :DateTime
|
167
|
+
DateTime.parse(value)
|
168
|
+
when :Date
|
169
|
+
Date.parse(value)
|
170
|
+
when :String
|
171
|
+
value.to_s
|
172
|
+
when :Integer
|
173
|
+
value.to_i
|
174
|
+
when :Float
|
175
|
+
value.to_f
|
176
|
+
when :BOOLEAN
|
177
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
178
|
+
true
|
179
|
+
else
|
180
|
+
false
|
181
|
+
end
|
182
|
+
when :Object
|
183
|
+
# generic object (usually a Hash), return directly
|
184
|
+
value
|
185
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
186
|
+
inner_type = Regexp.last_match[:inner_type]
|
187
|
+
value.map { |v| _deserialize(inner_type, v) }
|
188
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
189
|
+
k_type = Regexp.last_match[:k_type]
|
190
|
+
v_type = Regexp.last_match[:v_type]
|
191
|
+
{}.tap do |hash|
|
192
|
+
value.each do |k, v|
|
193
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
else # model
|
197
|
+
temp_model = Harbor2Client.const_get(type).new
|
198
|
+
temp_model.build_from_hash(value)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
# Returns the string representation of the object
|
203
|
+
# @return [String] String presentation of the object
|
204
|
+
def to_s
|
205
|
+
to_hash.to_s
|
206
|
+
end
|
207
|
+
|
208
|
+
# to_body is an alias to to_hash (backward compatibility)
|
209
|
+
# @return [Hash] Returns the object in the form of hash
|
210
|
+
def to_body
|
211
|
+
to_hash
|
212
|
+
end
|
213
|
+
|
214
|
+
# Returns the object in the form of hash
|
215
|
+
# @return [Hash] Returns the object in the form of hash
|
216
|
+
def to_hash
|
217
|
+
hash = {}
|
218
|
+
self.class.attribute_map.each_pair do |attr, param|
|
219
|
+
value = self.send(attr)
|
220
|
+
next if value.nil?
|
221
|
+
hash[param] = _to_hash(value)
|
222
|
+
end
|
223
|
+
hash
|
224
|
+
end
|
225
|
+
|
226
|
+
# Outputs non-array value in the form of hash
|
227
|
+
# For object, use to_hash. Otherwise, just return the value
|
228
|
+
# @param [Object] value Any valid value
|
229
|
+
# @return [Hash] Returns the value in the form of hash
|
230
|
+
def _to_hash(value)
|
231
|
+
if value.is_a?(Array)
|
232
|
+
value.compact.map { |v| _to_hash(v) }
|
233
|
+
elsif value.is_a?(Hash)
|
234
|
+
{}.tap do |hash|
|
235
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
236
|
+
end
|
237
|
+
elsif value.respond_to? :to_hash
|
238
|
+
value.to_hash
|
239
|
+
else
|
240
|
+
value
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
245
|
+
end
|
@@ -0,0 +1,235 @@
|
|
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 ProjectReq
|
17
|
+
# The name of the project.
|
18
|
+
attr_accessor :project_name
|
19
|
+
|
20
|
+
# deprecated, reserved for project creation in replication
|
21
|
+
attr_accessor :public
|
22
|
+
|
23
|
+
# The metadata of the project.
|
24
|
+
attr_accessor :metadata
|
25
|
+
|
26
|
+
# The CVE allowlist of the project.
|
27
|
+
attr_accessor :cve_allowlist
|
28
|
+
|
29
|
+
# The storage quota of the project.
|
30
|
+
attr_accessor :storage_limit
|
31
|
+
|
32
|
+
# The ID of referenced registry when creating the proxy cache project
|
33
|
+
attr_accessor :registry_id
|
34
|
+
|
35
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
36
|
+
def self.attribute_map
|
37
|
+
{
|
38
|
+
:'project_name' => :'project_name',
|
39
|
+
:'public' => :'public',
|
40
|
+
:'metadata' => :'metadata',
|
41
|
+
:'cve_allowlist' => :'cve_allowlist',
|
42
|
+
:'storage_limit' => :'storage_limit',
|
43
|
+
:'registry_id' => :'registry_id'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
# Attribute type mapping.
|
48
|
+
def self.swagger_types
|
49
|
+
{
|
50
|
+
:'project_name' => :'String',
|
51
|
+
:'public' => :'BOOLEAN',
|
52
|
+
:'metadata' => :'ProjectMetadata',
|
53
|
+
:'cve_allowlist' => :'CVEAllowlist',
|
54
|
+
:'storage_limit' => :'Integer',
|
55
|
+
:'registry_id' => :'Integer'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
# Initializes the object
|
60
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
61
|
+
def initialize(attributes = {})
|
62
|
+
return unless attributes.is_a?(Hash)
|
63
|
+
|
64
|
+
# convert string to symbol for hash key
|
65
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
66
|
+
|
67
|
+
if attributes.has_key?(:'project_name')
|
68
|
+
self.project_name = attributes[:'project_name']
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.has_key?(:'public')
|
72
|
+
self.public = attributes[:'public']
|
73
|
+
end
|
74
|
+
|
75
|
+
if attributes.has_key?(:'metadata')
|
76
|
+
self.metadata = attributes[:'metadata']
|
77
|
+
end
|
78
|
+
|
79
|
+
if attributes.has_key?(:'cve_allowlist')
|
80
|
+
self.cve_allowlist = attributes[:'cve_allowlist']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes.has_key?(:'storage_limit')
|
84
|
+
self.storage_limit = attributes[:'storage_limit']
|
85
|
+
end
|
86
|
+
|
87
|
+
if attributes.has_key?(:'registry_id')
|
88
|
+
self.registry_id = attributes[:'registry_id']
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
93
|
+
# @return Array for valid properties with the reasons
|
94
|
+
def list_invalid_properties
|
95
|
+
invalid_properties = Array.new
|
96
|
+
invalid_properties
|
97
|
+
end
|
98
|
+
|
99
|
+
# Check to see if the all the properties in the model are valid
|
100
|
+
# @return true if the model is valid
|
101
|
+
def valid?
|
102
|
+
true
|
103
|
+
end
|
104
|
+
|
105
|
+
# Checks equality by comparing each attribute.
|
106
|
+
# @param [Object] Object to be compared
|
107
|
+
def ==(o)
|
108
|
+
return true if self.equal?(o)
|
109
|
+
self.class == o.class &&
|
110
|
+
project_name == o.project_name &&
|
111
|
+
public == o.public &&
|
112
|
+
metadata == o.metadata &&
|
113
|
+
cve_allowlist == o.cve_allowlist &&
|
114
|
+
storage_limit == o.storage_limit &&
|
115
|
+
registry_id == o.registry_id
|
116
|
+
end
|
117
|
+
|
118
|
+
# @see the `==` method
|
119
|
+
# @param [Object] Object to be compared
|
120
|
+
def eql?(o)
|
121
|
+
self == o
|
122
|
+
end
|
123
|
+
|
124
|
+
# Calculates hash code according to all attributes.
|
125
|
+
# @return [Fixnum] Hash code
|
126
|
+
def hash
|
127
|
+
[project_name, public, metadata, cve_allowlist, storage_limit, registry_id].hash
|
128
|
+
end
|
129
|
+
|
130
|
+
# Builds the object from hash
|
131
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
132
|
+
# @return [Object] Returns the model itself
|
133
|
+
def build_from_hash(attributes)
|
134
|
+
return nil unless attributes.is_a?(Hash)
|
135
|
+
self.class.swagger_types.each_pair do |key, type|
|
136
|
+
if type =~ /\AArray<(.*)>/i
|
137
|
+
# check to ensure the input is an array given that the attribute
|
138
|
+
# is documented as an array but the input is not
|
139
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
140
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
141
|
+
end
|
142
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
143
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
144
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
145
|
+
end
|
146
|
+
|
147
|
+
self
|
148
|
+
end
|
149
|
+
|
150
|
+
# Deserializes the data based on type
|
151
|
+
# @param string type Data type
|
152
|
+
# @param string value Value to be deserialized
|
153
|
+
# @return [Object] Deserialized data
|
154
|
+
def _deserialize(type, value)
|
155
|
+
case type.to_sym
|
156
|
+
when :DateTime
|
157
|
+
DateTime.parse(value)
|
158
|
+
when :Date
|
159
|
+
Date.parse(value)
|
160
|
+
when :String
|
161
|
+
value.to_s
|
162
|
+
when :Integer
|
163
|
+
value.to_i
|
164
|
+
when :Float
|
165
|
+
value.to_f
|
166
|
+
when :BOOLEAN
|
167
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
168
|
+
true
|
169
|
+
else
|
170
|
+
false
|
171
|
+
end
|
172
|
+
when :Object
|
173
|
+
# generic object (usually a Hash), return directly
|
174
|
+
value
|
175
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
176
|
+
inner_type = Regexp.last_match[:inner_type]
|
177
|
+
value.map { |v| _deserialize(inner_type, v) }
|
178
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
179
|
+
k_type = Regexp.last_match[:k_type]
|
180
|
+
v_type = Regexp.last_match[:v_type]
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each do |k, v|
|
183
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
else # model
|
187
|
+
temp_model = Harbor2Client.const_get(type).new
|
188
|
+
temp_model.build_from_hash(value)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
# Returns the string representation of the object
|
193
|
+
# @return [String] String presentation of the object
|
194
|
+
def to_s
|
195
|
+
to_hash.to_s
|
196
|
+
end
|
197
|
+
|
198
|
+
# to_body is an alias to to_hash (backward compatibility)
|
199
|
+
# @return [Hash] Returns the object in the form of hash
|
200
|
+
def to_body
|
201
|
+
to_hash
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns the object in the form of hash
|
205
|
+
# @return [Hash] Returns the object in the form of hash
|
206
|
+
def to_hash
|
207
|
+
hash = {}
|
208
|
+
self.class.attribute_map.each_pair do |attr, param|
|
209
|
+
value = self.send(attr)
|
210
|
+
next if value.nil?
|
211
|
+
hash[param] = _to_hash(value)
|
212
|
+
end
|
213
|
+
hash
|
214
|
+
end
|
215
|
+
|
216
|
+
# Outputs non-array value in the form of hash
|
217
|
+
# For object, use to_hash. Otherwise, just return the value
|
218
|
+
# @param [Object] value Any valid value
|
219
|
+
# @return [Hash] Returns the value in the form of hash
|
220
|
+
def _to_hash(value)
|
221
|
+
if value.is_a?(Array)
|
222
|
+
value.compact.map { |v| _to_hash(v) }
|
223
|
+
elsif value.is_a?(Hash)
|
224
|
+
{}.tap do |hash|
|
225
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
226
|
+
end
|
227
|
+
elsif value.respond_to? :to_hash
|
228
|
+
value.to_hash
|
229
|
+
else
|
230
|
+
value
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
end
|