pulp_gem_client 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/README.md +15 -5
- data/docs/ContentGemApi.md +3 -1
- data/docs/DistributionsGemApi.md +119 -1
- data/docs/PublicationsGemApi.md +3 -1
- data/docs/RemotesGemApi.md +119 -1
- data/docs/RepositoriesGemApi.md +119 -1
- data/docs/RepositoriesGemVersionsApi.md +3 -1
- data/docs/SetLabel.md +19 -0
- data/docs/SetLabelResponse.md +19 -0
- data/docs/UnsetLabel.md +17 -0
- data/docs/UnsetLabelResponse.md +19 -0
- data/lib/pulp_gem_client/api/content_gem_api.rb +3 -0
- data/lib/pulp_gem_client/api/distributions_gem_api.rb +149 -0
- data/lib/pulp_gem_client/api/publications_gem_api.rb +3 -0
- data/lib/pulp_gem_client/api/remotes_gem_api.rb +149 -0
- data/lib/pulp_gem_client/api/repositories_gem_api.rb +149 -0
- data/lib/pulp_gem_client/api/repositories_gem_versions_api.rb +3 -0
- data/lib/pulp_gem_client/configuration.rb +2 -2
- data/lib/pulp_gem_client/models/set_label.rb +252 -0
- data/lib/pulp_gem_client/models/set_label_response.rb +243 -0
- data/lib/pulp_gem_client/models/unset_label.rb +242 -0
- data/lib/pulp_gem_client/models/unset_label_response.rb +242 -0
- data/lib/pulp_gem_client/version.rb +1 -1
- data/lib/pulp_gem_client.rb +4 -0
- data/spec/api/content_gem_api_spec.rb +1 -0
- data/spec/api/distributions_gem_api_spec.rb +29 -0
- data/spec/api/publications_gem_api_spec.rb +1 -0
- data/spec/api/remotes_gem_api_spec.rb +29 -0
- data/spec/api/repositories_gem_api_spec.rb +29 -0
- data/spec/api/repositories_gem_versions_api_spec.rb +1 -0
- data/spec/configuration_spec.rb +3 -3
- data/spec/models/set_label_response_spec.rb +47 -0
- data/spec/models/set_label_spec.rb +47 -0
- data/spec/models/unset_label_response_spec.rb +47 -0
- data/spec/models/unset_label_spec.rb +41 -0
- metadata +37 -21
@@ -153,13 +153,16 @@ module PulpGemClient
|
|
153
153
|
# @option opts [String] :name Filter results where name matches value
|
154
154
|
# @option opts [String] :name__contains Filter results where name contains value
|
155
155
|
# @option opts [String] :name__icontains Filter results where name contains value
|
156
|
+
# @option opts [String] :name__iexact Filter results where name matches value
|
156
157
|
# @option opts [Array<String>] :name__in Filter results where name is in a comma-separated list of values
|
158
|
+
# @option opts [String] :name__istartswith Filter results where name starts with value
|
157
159
|
# @option opts [String] :name__startswith Filter results where name starts with value
|
158
160
|
# @option opts [Integer] :offset The initial index from which to return the results.
|
159
161
|
# @option opts [Array<String>] :ordering Ordering * `pulp_id` - Pulp id * `-pulp_id` - Pulp id (descending) * `pulp_created` - Pulp created * `-pulp_created` - Pulp created (descending) * `pulp_last_updated` - Pulp last updated * `-pulp_last_updated` - Pulp last updated (descending) * `pulp_type` - Pulp type * `-pulp_type` - Pulp type (descending) * `name` - Name * `-name` - Name (descending) * `pulp_labels` - Pulp labels * `-pulp_labels` - Pulp labels (descending) * `description` - Description * `-description` - Description (descending) * `next_version` - Next version * `-next_version` - Next version (descending) * `retain_repo_versions` - Retain repo versions * `-retain_repo_versions` - Retain repo versions (descending) * `user_hidden` - User hidden * `-user_hidden` - User hidden (descending) * `pk` - Pk * `-pk` - Pk (descending)
|
160
162
|
# @option opts [Array<String>] :pulp_href__in Multiple values may be separated by commas.
|
161
163
|
# @option opts [Array<String>] :pulp_id__in Multiple values may be separated by commas.
|
162
164
|
# @option opts [String] :pulp_label_select Filter labels by search string
|
165
|
+
# @option opts [String] :q
|
163
166
|
# @option opts [String] :remote Foreign Key referenced by HREF
|
164
167
|
# @option opts [Integer] :retain_repo_versions Filter results where retain_repo_versions matches value
|
165
168
|
# @option opts [Integer] :retain_repo_versions__gt Filter results where retain_repo_versions is greater than value
|
@@ -186,13 +189,16 @@ module PulpGemClient
|
|
186
189
|
# @option opts [String] :name Filter results where name matches value
|
187
190
|
# @option opts [String] :name__contains Filter results where name contains value
|
188
191
|
# @option opts [String] :name__icontains Filter results where name contains value
|
192
|
+
# @option opts [String] :name__iexact Filter results where name matches value
|
189
193
|
# @option opts [Array<String>] :name__in Filter results where name is in a comma-separated list of values
|
194
|
+
# @option opts [String] :name__istartswith Filter results where name starts with value
|
190
195
|
# @option opts [String] :name__startswith Filter results where name starts with value
|
191
196
|
# @option opts [Integer] :offset The initial index from which to return the results.
|
192
197
|
# @option opts [Array<String>] :ordering Ordering * `pulp_id` - Pulp id * `-pulp_id` - Pulp id (descending) * `pulp_created` - Pulp created * `-pulp_created` - Pulp created (descending) * `pulp_last_updated` - Pulp last updated * `-pulp_last_updated` - Pulp last updated (descending) * `pulp_type` - Pulp type * `-pulp_type` - Pulp type (descending) * `name` - Name * `-name` - Name (descending) * `pulp_labels` - Pulp labels * `-pulp_labels` - Pulp labels (descending) * `description` - Description * `-description` - Description (descending) * `next_version` - Next version * `-next_version` - Next version (descending) * `retain_repo_versions` - Retain repo versions * `-retain_repo_versions` - Retain repo versions (descending) * `user_hidden` - User hidden * `-user_hidden` - User hidden (descending) * `pk` - Pk * `-pk` - Pk (descending)
|
193
198
|
# @option opts [Array<String>] :pulp_href__in Multiple values may be separated by commas.
|
194
199
|
# @option opts [Array<String>] :pulp_id__in Multiple values may be separated by commas.
|
195
200
|
# @option opts [String] :pulp_label_select Filter labels by search string
|
201
|
+
# @option opts [String] :q
|
196
202
|
# @option opts [String] :remote Foreign Key referenced by HREF
|
197
203
|
# @option opts [Integer] :retain_repo_versions Filter results where retain_repo_versions matches value
|
198
204
|
# @option opts [Integer] :retain_repo_versions__gt Filter results where retain_repo_versions is greater than value
|
@@ -224,13 +230,16 @@ module PulpGemClient
|
|
224
230
|
query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?
|
225
231
|
query_params[:'name__contains'] = opts[:'name__contains'] if !opts[:'name__contains'].nil?
|
226
232
|
query_params[:'name__icontains'] = opts[:'name__icontains'] if !opts[:'name__icontains'].nil?
|
233
|
+
query_params[:'name__iexact'] = opts[:'name__iexact'] if !opts[:'name__iexact'].nil?
|
227
234
|
query_params[:'name__in'] = @api_client.build_collection_param(opts[:'name__in'], :csv) if !opts[:'name__in'].nil?
|
235
|
+
query_params[:'name__istartswith'] = opts[:'name__istartswith'] if !opts[:'name__istartswith'].nil?
|
228
236
|
query_params[:'name__startswith'] = opts[:'name__startswith'] if !opts[:'name__startswith'].nil?
|
229
237
|
query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
|
230
238
|
query_params[:'ordering'] = @api_client.build_collection_param(opts[:'ordering'], :csv) if !opts[:'ordering'].nil?
|
231
239
|
query_params[:'pulp_href__in'] = @api_client.build_collection_param(opts[:'pulp_href__in'], :csv) if !opts[:'pulp_href__in'].nil?
|
232
240
|
query_params[:'pulp_id__in'] = @api_client.build_collection_param(opts[:'pulp_id__in'], :csv) if !opts[:'pulp_id__in'].nil?
|
233
241
|
query_params[:'pulp_label_select'] = opts[:'pulp_label_select'] if !opts[:'pulp_label_select'].nil?
|
242
|
+
query_params[:'q'] = opts[:'q'] if !opts[:'q'].nil?
|
234
243
|
query_params[:'remote'] = opts[:'remote'] if !opts[:'remote'].nil?
|
235
244
|
query_params[:'retain_repo_versions'] = opts[:'retain_repo_versions'] if !opts[:'retain_repo_versions'].nil?
|
236
245
|
query_params[:'retain_repo_versions__gt'] = opts[:'retain_repo_versions__gt'] if !opts[:'retain_repo_versions__gt'].nil?
|
@@ -485,6 +494,76 @@ module PulpGemClient
|
|
485
494
|
return data, status_code, headers
|
486
495
|
end
|
487
496
|
|
497
|
+
# Set a label
|
498
|
+
# Set a single pulp_label on the object to a specific value or null.
|
499
|
+
# @param gem_gem_repository_href [String]
|
500
|
+
# @param set_label [SetLabel]
|
501
|
+
# @param [Hash] opts the optional parameters
|
502
|
+
# @return [SetLabelResponse]
|
503
|
+
def set_label(gem_gem_repository_href, set_label, opts = {})
|
504
|
+
data, _status_code, _headers = set_label_with_http_info(gem_gem_repository_href, set_label, opts)
|
505
|
+
data
|
506
|
+
end
|
507
|
+
|
508
|
+
# Set a label
|
509
|
+
# Set a single pulp_label on the object to a specific value or null.
|
510
|
+
# @param gem_gem_repository_href [String]
|
511
|
+
# @param set_label [SetLabel]
|
512
|
+
# @param [Hash] opts the optional parameters
|
513
|
+
# @return [Array<(SetLabelResponse, Integer, Hash)>] SetLabelResponse data, response status code and response headers
|
514
|
+
def set_label_with_http_info(gem_gem_repository_href, set_label, opts = {})
|
515
|
+
if @api_client.config.debugging
|
516
|
+
@api_client.config.logger.debug 'Calling API: RepositoriesGemApi.set_label ...'
|
517
|
+
end
|
518
|
+
# verify the required parameter 'gem_gem_repository_href' is set
|
519
|
+
if @api_client.config.client_side_validation && gem_gem_repository_href.nil?
|
520
|
+
fail ArgumentError, "Missing the required parameter 'gem_gem_repository_href' when calling RepositoriesGemApi.set_label"
|
521
|
+
end
|
522
|
+
# verify the required parameter 'set_label' is set
|
523
|
+
if @api_client.config.client_side_validation && set_label.nil?
|
524
|
+
fail ArgumentError, "Missing the required parameter 'set_label' when calling RepositoriesGemApi.set_label"
|
525
|
+
end
|
526
|
+
# resource path
|
527
|
+
local_var_path = '{gem_gem_repository_href}set_label/'.sub('{' + 'gem_gem_repository_href' + '}', CGI.escape(gem_gem_repository_href.to_s).gsub('%2F', '/'))
|
528
|
+
|
529
|
+
# query parameters
|
530
|
+
query_params = opts[:query_params] || {}
|
531
|
+
|
532
|
+
# header parameters
|
533
|
+
header_params = opts[:header_params] || {}
|
534
|
+
# HTTP header 'Accept' (if needed)
|
535
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
536
|
+
# HTTP header 'Content-Type'
|
537
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded', 'multipart/form-data'])
|
538
|
+
|
539
|
+
# form parameters
|
540
|
+
form_params = opts[:form_params] || {}
|
541
|
+
|
542
|
+
# http body (model)
|
543
|
+
post_body = opts[:body] || @api_client.object_to_http_body(set_label)
|
544
|
+
|
545
|
+
# return_type
|
546
|
+
return_type = opts[:return_type] || 'SetLabelResponse'
|
547
|
+
|
548
|
+
# auth_names
|
549
|
+
auth_names = opts[:auth_names] || ['basicAuth']
|
550
|
+
|
551
|
+
new_options = opts.merge(
|
552
|
+
:header_params => header_params,
|
553
|
+
:query_params => query_params,
|
554
|
+
:form_params => form_params,
|
555
|
+
:body => post_body,
|
556
|
+
:auth_names => auth_names,
|
557
|
+
:return_type => return_type
|
558
|
+
)
|
559
|
+
|
560
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
561
|
+
if @api_client.config.debugging
|
562
|
+
@api_client.config.logger.debug "API called: RepositoriesGemApi#set_label\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
563
|
+
end
|
564
|
+
return data, status_code, headers
|
565
|
+
end
|
566
|
+
|
488
567
|
# Sync from a remote
|
489
568
|
# Trigger an asynchronous task to sync gem content.
|
490
569
|
# @param gem_gem_repository_href [String]
|
@@ -555,6 +634,76 @@ module PulpGemClient
|
|
555
634
|
return data, status_code, headers
|
556
635
|
end
|
557
636
|
|
637
|
+
# Unset a label
|
638
|
+
# Unset a single pulp_label on the object.
|
639
|
+
# @param gem_gem_repository_href [String]
|
640
|
+
# @param unset_label [UnsetLabel]
|
641
|
+
# @param [Hash] opts the optional parameters
|
642
|
+
# @return [UnsetLabelResponse]
|
643
|
+
def unset_label(gem_gem_repository_href, unset_label, opts = {})
|
644
|
+
data, _status_code, _headers = unset_label_with_http_info(gem_gem_repository_href, unset_label, opts)
|
645
|
+
data
|
646
|
+
end
|
647
|
+
|
648
|
+
# Unset a label
|
649
|
+
# Unset a single pulp_label on the object.
|
650
|
+
# @param gem_gem_repository_href [String]
|
651
|
+
# @param unset_label [UnsetLabel]
|
652
|
+
# @param [Hash] opts the optional parameters
|
653
|
+
# @return [Array<(UnsetLabelResponse, Integer, Hash)>] UnsetLabelResponse data, response status code and response headers
|
654
|
+
def unset_label_with_http_info(gem_gem_repository_href, unset_label, opts = {})
|
655
|
+
if @api_client.config.debugging
|
656
|
+
@api_client.config.logger.debug 'Calling API: RepositoriesGemApi.unset_label ...'
|
657
|
+
end
|
658
|
+
# verify the required parameter 'gem_gem_repository_href' is set
|
659
|
+
if @api_client.config.client_side_validation && gem_gem_repository_href.nil?
|
660
|
+
fail ArgumentError, "Missing the required parameter 'gem_gem_repository_href' when calling RepositoriesGemApi.unset_label"
|
661
|
+
end
|
662
|
+
# verify the required parameter 'unset_label' is set
|
663
|
+
if @api_client.config.client_side_validation && unset_label.nil?
|
664
|
+
fail ArgumentError, "Missing the required parameter 'unset_label' when calling RepositoriesGemApi.unset_label"
|
665
|
+
end
|
666
|
+
# resource path
|
667
|
+
local_var_path = '{gem_gem_repository_href}unset_label/'.sub('{' + 'gem_gem_repository_href' + '}', CGI.escape(gem_gem_repository_href.to_s).gsub('%2F', '/'))
|
668
|
+
|
669
|
+
# query parameters
|
670
|
+
query_params = opts[:query_params] || {}
|
671
|
+
|
672
|
+
# header parameters
|
673
|
+
header_params = opts[:header_params] || {}
|
674
|
+
# HTTP header 'Accept' (if needed)
|
675
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
676
|
+
# HTTP header 'Content-Type'
|
677
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded', 'multipart/form-data'])
|
678
|
+
|
679
|
+
# form parameters
|
680
|
+
form_params = opts[:form_params] || {}
|
681
|
+
|
682
|
+
# http body (model)
|
683
|
+
post_body = opts[:body] || @api_client.object_to_http_body(unset_label)
|
684
|
+
|
685
|
+
# return_type
|
686
|
+
return_type = opts[:return_type] || 'UnsetLabelResponse'
|
687
|
+
|
688
|
+
# auth_names
|
689
|
+
auth_names = opts[:auth_names] || ['basicAuth']
|
690
|
+
|
691
|
+
new_options = opts.merge(
|
692
|
+
:header_params => header_params,
|
693
|
+
:query_params => query_params,
|
694
|
+
:form_params => form_params,
|
695
|
+
:body => post_body,
|
696
|
+
:auth_names => auth_names,
|
697
|
+
:return_type => return_type
|
698
|
+
)
|
699
|
+
|
700
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
701
|
+
if @api_client.config.debugging
|
702
|
+
@api_client.config.logger.debug "API called: RepositoriesGemApi#unset_label\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
703
|
+
end
|
704
|
+
return data, status_code, headers
|
705
|
+
end
|
706
|
+
|
558
707
|
# Update a gem repository
|
559
708
|
# Trigger an asynchronous update task
|
560
709
|
# @param gem_gem_repository_href [String]
|
@@ -103,6 +103,7 @@ module PulpGemClient
|
|
103
103
|
# @option opts [DateTime] :pulp_created__lte Filter results where pulp_created is less than or equal to value
|
104
104
|
# @option opts [Array<DateTime>] :pulp_created__range Filter results where pulp_created is between two comma separated values
|
105
105
|
# @option opts [Array<String>] :pulp_href__in Multiple values may be separated by commas.
|
106
|
+
# @option opts [String] :q
|
106
107
|
# @option opts [Array<String>] :fields A list of fields to include in the response.
|
107
108
|
# @option opts [Array<String>] :exclude_fields A list of fields to exclude from the response.
|
108
109
|
# @return [PaginatedRepositoryVersionResponseList]
|
@@ -133,6 +134,7 @@ module PulpGemClient
|
|
133
134
|
# @option opts [DateTime] :pulp_created__lte Filter results where pulp_created is less than or equal to value
|
134
135
|
# @option opts [Array<DateTime>] :pulp_created__range Filter results where pulp_created is between two comma separated values
|
135
136
|
# @option opts [Array<String>] :pulp_href__in Multiple values may be separated by commas.
|
137
|
+
# @option opts [String] :q
|
136
138
|
# @option opts [Array<String>] :fields A list of fields to include in the response.
|
137
139
|
# @option opts [Array<String>] :exclude_fields A list of fields to exclude from the response.
|
138
140
|
# @return [Array<(PaginatedRepositoryVersionResponseList, Integer, Hash)>] PaginatedRepositoryVersionResponseList data, response status code and response headers
|
@@ -171,6 +173,7 @@ module PulpGemClient
|
|
171
173
|
query_params[:'pulp_created__lte'] = opts[:'pulp_created__lte'] if !opts[:'pulp_created__lte'].nil?
|
172
174
|
query_params[:'pulp_created__range'] = @api_client.build_collection_param(opts[:'pulp_created__range'], :csv) if !opts[:'pulp_created__range'].nil?
|
173
175
|
query_params[:'pulp_href__in'] = @api_client.build_collection_param(opts[:'pulp_href__in'], :csv) if !opts[:'pulp_href__in'].nil?
|
176
|
+
query_params[:'q'] = opts[:'q'] if !opts[:'q'].nil?
|
174
177
|
query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :multi) if !opts[:'fields'].nil?
|
175
178
|
query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :multi) if !opts[:'exclude_fields'].nil?
|
176
179
|
|
@@ -127,7 +127,7 @@ module PulpGemClient
|
|
127
127
|
attr_accessor :force_ending_format
|
128
128
|
|
129
129
|
def initialize
|
130
|
-
@scheme = '
|
130
|
+
@scheme = 'http'
|
131
131
|
@host = 'pulp'
|
132
132
|
@base_path = ''
|
133
133
|
@api_key = {}
|
@@ -210,7 +210,7 @@ module PulpGemClient
|
|
210
210
|
def server_settings
|
211
211
|
[
|
212
212
|
{
|
213
|
-
url: "
|
213
|
+
url: "http://pulp/",
|
214
214
|
description: "No description provided",
|
215
215
|
}
|
216
216
|
]
|
@@ -0,0 +1,252 @@
|
|
1
|
+
=begin
|
2
|
+
#Pulp 3 API
|
3
|
+
|
4
|
+
#Fetch, Upload, Organize, and Distribute Software Packages
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v3
|
7
|
+
Contact: pulp-list@redhat.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpGemClient
|
16
|
+
# Serializer for synchronously setting a label.
|
17
|
+
class SetLabel
|
18
|
+
attr_accessor :key
|
19
|
+
|
20
|
+
attr_accessor :value
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'key' => :'key',
|
26
|
+
:'value' => :'value'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Attribute type mapping.
|
31
|
+
def self.openapi_types
|
32
|
+
{
|
33
|
+
:'key' => :'String',
|
34
|
+
:'value' => :'String'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# List of attributes with nullable: true
|
39
|
+
def self.openapi_nullable
|
40
|
+
Set.new([
|
41
|
+
:'value'
|
42
|
+
])
|
43
|
+
end
|
44
|
+
|
45
|
+
# Initializes the object
|
46
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
47
|
+
def initialize(attributes = {})
|
48
|
+
if (!attributes.is_a?(Hash))
|
49
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpGemClient::SetLabel` initialize method"
|
50
|
+
end
|
51
|
+
|
52
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
53
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
54
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
55
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpGemClient::SetLabel`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
56
|
+
end
|
57
|
+
h[k.to_sym] = v
|
58
|
+
}
|
59
|
+
|
60
|
+
if attributes.key?(:'key')
|
61
|
+
self.key = attributes[:'key']
|
62
|
+
end
|
63
|
+
|
64
|
+
if attributes.key?(:'value')
|
65
|
+
self.value = attributes[:'value']
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
70
|
+
# @return Array for valid properties with the reasons
|
71
|
+
def list_invalid_properties
|
72
|
+
invalid_properties = Array.new
|
73
|
+
if @key.nil?
|
74
|
+
invalid_properties.push('invalid value for "key", key cannot be nil.')
|
75
|
+
end
|
76
|
+
|
77
|
+
if @key.to_s.length < 1
|
78
|
+
invalid_properties.push('invalid value for "key", the character length must be great than or equal to 1.')
|
79
|
+
end
|
80
|
+
|
81
|
+
pattern = Regexp.new(/^[-a-zA-Z0-9_]+$/)
|
82
|
+
if @key !~ pattern
|
83
|
+
invalid_properties.push("invalid value for \"key\", must conform to the pattern #{pattern}.")
|
84
|
+
end
|
85
|
+
|
86
|
+
invalid_properties
|
87
|
+
end
|
88
|
+
|
89
|
+
# Check to see if the all the properties in the model are valid
|
90
|
+
# @return true if the model is valid
|
91
|
+
def valid?
|
92
|
+
return false if @key.nil?
|
93
|
+
return false if @key.to_s.length < 1
|
94
|
+
return false if @key !~ Regexp.new(/^[-a-zA-Z0-9_]+$/)
|
95
|
+
true
|
96
|
+
end
|
97
|
+
|
98
|
+
# Custom attribute writer method with validation
|
99
|
+
# @param [Object] key Value to be assigned
|
100
|
+
def key=(key)
|
101
|
+
if key.nil?
|
102
|
+
fail ArgumentError, 'key cannot be nil'
|
103
|
+
end
|
104
|
+
|
105
|
+
if key.to_s.length < 1
|
106
|
+
fail ArgumentError, 'invalid value for "key", the character length must be great than or equal to 1.'
|
107
|
+
end
|
108
|
+
|
109
|
+
pattern = Regexp.new(/^[-a-zA-Z0-9_]+$/)
|
110
|
+
if key !~ pattern
|
111
|
+
fail ArgumentError, "invalid value for \"key\", must conform to the pattern #{pattern}."
|
112
|
+
end
|
113
|
+
|
114
|
+
@key = key
|
115
|
+
end
|
116
|
+
|
117
|
+
# Checks equality by comparing each attribute.
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def ==(o)
|
120
|
+
return true if self.equal?(o)
|
121
|
+
self.class == o.class &&
|
122
|
+
key == o.key &&
|
123
|
+
value == o.value
|
124
|
+
end
|
125
|
+
|
126
|
+
# @see the `==` method
|
127
|
+
# @param [Object] Object to be compared
|
128
|
+
def eql?(o)
|
129
|
+
self == o
|
130
|
+
end
|
131
|
+
|
132
|
+
# Calculates hash code according to all attributes.
|
133
|
+
# @return [Integer] Hash code
|
134
|
+
def hash
|
135
|
+
[key, value].hash
|
136
|
+
end
|
137
|
+
|
138
|
+
# Builds the object from hash
|
139
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
140
|
+
# @return [Object] Returns the model itself
|
141
|
+
def self.build_from_hash(attributes)
|
142
|
+
new.build_from_hash(attributes)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Builds the object from hash
|
146
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
147
|
+
# @return [Object] Returns the model itself
|
148
|
+
def build_from_hash(attributes)
|
149
|
+
return nil unless attributes.is_a?(Hash)
|
150
|
+
self.class.openapi_types.each_pair do |key, type|
|
151
|
+
if type =~ /\AArray<(.*)>/i
|
152
|
+
# check to ensure the input is an array given that the attribute
|
153
|
+
# is documented as an array but the input is not
|
154
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
155
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
156
|
+
end
|
157
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
158
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
159
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
160
|
+
end
|
161
|
+
|
162
|
+
self
|
163
|
+
end
|
164
|
+
|
165
|
+
# Deserializes the data based on type
|
166
|
+
# @param string type Data type
|
167
|
+
# @param string value Value to be deserialized
|
168
|
+
# @return [Object] Deserialized data
|
169
|
+
def _deserialize(type, value)
|
170
|
+
case type.to_sym
|
171
|
+
when :DateTime
|
172
|
+
DateTime.parse(value)
|
173
|
+
when :Date
|
174
|
+
Date.parse(value)
|
175
|
+
when :String
|
176
|
+
value.to_s
|
177
|
+
when :Integer
|
178
|
+
value.to_i
|
179
|
+
when :Float
|
180
|
+
value.to_f
|
181
|
+
when :Boolean
|
182
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
183
|
+
true
|
184
|
+
else
|
185
|
+
false
|
186
|
+
end
|
187
|
+
when :Object
|
188
|
+
# generic object (usually a Hash), return directly
|
189
|
+
value
|
190
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
191
|
+
inner_type = Regexp.last_match[:inner_type]
|
192
|
+
value.map { |v| _deserialize(inner_type, v) }
|
193
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
194
|
+
k_type = Regexp.last_match[:k_type]
|
195
|
+
v_type = Regexp.last_match[:v_type]
|
196
|
+
{}.tap do |hash|
|
197
|
+
value.each do |k, v|
|
198
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
else # model
|
202
|
+
PulpGemClient.const_get(type).build_from_hash(value)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# Returns the string representation of the object
|
207
|
+
# @return [String] String presentation of the object
|
208
|
+
def to_s
|
209
|
+
to_hash.to_s
|
210
|
+
end
|
211
|
+
|
212
|
+
# to_body is an alias to to_hash (backward compatibility)
|
213
|
+
# @return [Hash] Returns the object in the form of hash
|
214
|
+
def to_body
|
215
|
+
to_hash
|
216
|
+
end
|
217
|
+
|
218
|
+
# Returns the object in the form of hash
|
219
|
+
# @return [Hash] Returns the object in the form of hash
|
220
|
+
def to_hash
|
221
|
+
hash = {}
|
222
|
+
self.class.attribute_map.each_pair do |attr, param|
|
223
|
+
value = self.send(attr)
|
224
|
+
if value.nil?
|
225
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
226
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
227
|
+
end
|
228
|
+
|
229
|
+
hash[param] = _to_hash(value)
|
230
|
+
end
|
231
|
+
hash
|
232
|
+
end
|
233
|
+
|
234
|
+
# Outputs non-array value in the form of hash
|
235
|
+
# For object, use to_hash. Otherwise, just return the value
|
236
|
+
# @param [Object] value Any valid value
|
237
|
+
# @return [Hash] Returns the value in the form of hash
|
238
|
+
def _to_hash(value)
|
239
|
+
if value.is_a?(Array)
|
240
|
+
value.compact.map { |v| _to_hash(v) }
|
241
|
+
elsif value.is_a?(Hash)
|
242
|
+
{}.tap do |hash|
|
243
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
244
|
+
end
|
245
|
+
elsif value.respond_to? :to_hash
|
246
|
+
value.to_hash
|
247
|
+
else
|
248
|
+
value
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|