Class: Katello::Pulp3::Api::Core
- Inherits:
-
Object
- Object
- Katello::Pulp3::Api::Core
show all
- Defined in:
- app/services/katello/pulp3/api/core.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(smart_proxy, repository_type = Katello::RepositoryTypeManager.find_by(:pulp3_api_class, self.class)) ⇒ Core
Returns a new instance of Core.
9
10
11
12
|
# File 'app/services/katello/pulp3/api/core.rb', line 9
def initialize(smart_proxy, repository_type = Katello::RepositoryTypeManager.find_by(:pulp3_api_class, self.class))
@smart_proxy = smart_proxy
@repository_type = repository_type
end
|
Instance Attribute Details
#repository_type ⇒ Object
Returns the value of attribute repository_type.
7
8
9
|
# File 'app/services/katello/pulp3/api/core.rb', line 7
def repository_type
@repository_type
end
|
#smart_proxy ⇒ Object
Returns the value of attribute smart_proxy.
7
8
9
|
# File 'app/services/katello/pulp3/api/core.rb', line 7
def smart_proxy
@smart_proxy
end
|
Class Method Details
.fetch_from_list ⇒ Object
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
# File 'app/services/katello/pulp3/api/core.rb', line 233
def self.fetch_from_list
page_size = Setting[:bulk_load_size]
page_opts = { "offset" => 0, limit: page_size }
response = {}
results = []
loop do
page_opts = page_opts.with_indifferent_access
break unless (
(response.count && (page_opts['offset'] < response.count)) ||
page_opts["offset"] == 0)
response = yield page_opts
results = results.concat(response.results)
page_opts[:offset] += page_size
end
results
end
|
.ignore_409_exception ⇒ Object
70
71
72
73
74
75
|
# File 'app/services/katello/pulp3/api/core.rb', line 70
def self.ignore_409_exception(*)
yield
rescue => e
raise e unless e&.code == 409
nil
end
|
.remote_uln_class ⇒ Object
20
21
22
|
# File 'app/services/katello/pulp3/api/core.rb', line 20
def self.remote_uln_class
fail NotImplementedError
end
|
Instance Method Details
#api_client ⇒ Object
32
33
34
35
36
|
# File 'app/services/katello/pulp3/api/core.rb', line 32
def api_client
config = smart_proxy.pulp3_configuration(repository_type.configuration_class)
config.params_encoder = Faraday::FlatParamsEncoder
api_client_class(repository_type.api_class.new(config))
end
|
#api_client_class(client) ⇒ Object
133
134
135
136
137
|
# File 'app/services/katello/pulp3/api/core.rb', line 133
def api_client_class(client)
request_id = ::Logging.mdc['request']
client.['Correlation-ID'] = request_id if request_id
client
end
|
#api_exception_class ⇒ Object
38
39
40
|
# File 'app/services/katello/pulp3/api/core.rb', line 38
def api_exception_class
client_module::ApiError
end
|
#artifacts_api ⇒ Object
124
125
126
|
# File 'app/services/katello/pulp3/api/core.rb', line 124
def artifacts_api
PulpcoreClient::ArtifactsApi.new(core_api_client)
end
|
#cancel_task(task_href) ⇒ Object
81
82
83
84
85
86
|
# File 'app/services/katello/pulp3/api/core.rb', line 81
def cancel_task(task_href)
data = PulpcoreClient::TaskResponse.new(state: 'canceled')
self.class.ignore_409_exception do
tasks_api.tasks_cancel(task_href, data)
end
end
|
#client_module ⇒ Object
14
15
16
|
# File 'app/services/katello/pulp3/api/core.rb', line 14
def client_module
repository_type.client_module_class
end
|
#core_api_client ⇒ Object
128
129
130
131
|
# File 'app/services/katello/pulp3/api/core.rb', line 128
def core_api_client
client = PulpcoreClient::ApiClient.new(smart_proxy.pulp3_configuration(PulpcoreClient::Configuration))
api_client_class(client)
end
|
#core_repositories_api ⇒ Object
58
59
60
|
# File 'app/services/katello/pulp3/api/core.rb', line 58
def core_repositories_api
PulpcoreClient::RepositoriesApi.new(core_api_client)
end
|
#core_repositories_list_all(options = {}) ⇒ Object
211
212
213
214
215
|
# File 'app/services/katello/pulp3/api/core.rb', line 211
def core_repositories_list_all(options = {})
self.class.fetch_from_list do |page_opts|
core_repositories_api.list(page_opts.merge(options))
end
end
|
#delete_distribution(href) ⇒ Object
207
208
209
|
# File 'app/services/katello/pulp3/api/core.rb', line 207
def delete_distribution(href)
ignore_404_exception { distributions_api.delete(href) }
end
|
#delete_orphans ⇒ Object
170
171
172
|
# File 'app/services/katello/pulp3/api/core.rb', line 170
def delete_orphans
[orphans_api.cleanup(PulpcoreClient::OrphansCleanup.new(orphan_protection_time: Setting[:orphan_protection_time]))]
end
|
#delete_remote(remote_href) ⇒ Object
174
175
176
|
# File 'app/services/katello/pulp3/api/core.rb', line 174
def delete_remote(remote_href)
ignore_404_exception { remotes_api.delete(remote_href) }
end
|
#distributions_api ⇒ Object
54
55
56
|
# File 'app/services/katello/pulp3/api/core.rb', line 54
def distributions_api
repository_type.distributions_api_class.new(api_client)
end
|
#distributions_list_all(args = {}) ⇒ Object
197
198
199
200
201
|
# File 'app/services/katello/pulp3/api/core.rb', line 197
def distributions_list_all(args = {})
self.class.fetch_from_list do |page_opts|
distributions_api.list(page_opts.merge(args))
end
end
|
#export_api ⇒ Object
112
113
114
|
# File 'app/services/katello/pulp3/api/core.rb', line 112
def export_api
PulpcoreClient::ExportersPulpExportsApi.new(core_api_client)
end
|
#exporter_api ⇒ Object
96
97
98
|
# File 'app/services/katello/pulp3/api/core.rb', line 96
def exporter_api
PulpcoreClient::ExportersPulpApi.new(core_api_client)
end
|
#get_distribution(href) ⇒ Object
203
204
205
|
# File 'app/services/katello/pulp3/api/core.rb', line 203
def get_distribution(href)
ignore_404_exception { distributions_api.read(href) }
end
|
#ignore_404_exception ⇒ Object
163
164
165
166
167
168
|
# File 'app/services/katello/pulp3/api/core.rb', line 163
def ignore_404_exception(*)
yield
rescue self.api_exception_class => e
raise e unless e.code == 404
nil
end
|
#import_api ⇒ Object
116
117
118
|
# File 'app/services/katello/pulp3/api/core.rb', line 116
def import_api
PulpcoreClient::ImportersPulpImportsApi.new(core_api_client)
end
|
#importer_api ⇒ Object
100
101
102
|
# File 'app/services/katello/pulp3/api/core.rb', line 100
def importer_api
PulpcoreClient::ImportersPulpApi.new(core_api_client)
end
|
#importer_check_api ⇒ Object
104
105
106
|
# File 'app/services/katello/pulp3/api/core.rb', line 104
def importer_check_api
PulpcoreClient::ImportersPulpImportCheckApi.new(core_api_client)
end
|
#list_all(options = {}) ⇒ Object
217
218
219
220
221
|
# File 'app/services/katello/pulp3/api/core.rb', line 217
def list_all(options = {})
self.class.fetch_from_list do |page_opts|
repositories_api.list(page_opts.merge(options))
end
end
|
#orphans_api ⇒ Object
120
121
122
|
# File 'app/services/katello/pulp3/api/core.rb', line 120
def orphans_api
PulpcoreClient::OrphansCleanupApi.new(core_api_client)
end
|
#publications_api ⇒ Object
50
51
52
|
# File 'app/services/katello/pulp3/api/core.rb', line 50
def publications_api
repository_type.publications_api_class.new(api_client) end
|
#remotes_api ⇒ Object
42
43
44
|
# File 'app/services/katello/pulp3/api/core.rb', line 42
def remotes_api
repository_type.remotes_api_class.new(api_client)
end
|
#remotes_list(args = {}) ⇒ Object
223
224
225
|
# File 'app/services/katello/pulp3/api/core.rb', line 223
def remotes_list(args = {})
remotes_api.list(args).results
end
|
#remotes_list_all(_smart_proxy, options) ⇒ Object
227
228
229
230
231
|
# File 'app/services/katello/pulp3/api/core.rb', line 227
def remotes_list_all(_smart_proxy, options)
self.class.fetch_from_list do |page_opts|
remotes_api.list(page_opts.merge(options))
end
end
|
#remotes_uln_api ⇒ Object
46
47
48
|
# File 'app/services/katello/pulp3/api/core.rb', line 46
def remotes_uln_api
fail NotImplementedError
end
|
#repair_class ⇒ Object
77
78
79
|
# File 'app/services/katello/pulp3/api/core.rb', line 77
def repair_class
client_module::Repair
end
|
#repositories_api ⇒ Object
62
63
64
|
# File 'app/services/katello/pulp3/api/core.rb', line 62
def repositories_api
repository_type.repositories_api_class.new(api_client)
end
|
#repositories_reclaim_space_api ⇒ Object
88
89
90
|
# File 'app/services/katello/pulp3/api/core.rb', line 88
def repositories_reclaim_space_api
PulpcoreClient::RepositoriesReclaimSpaceApi.new(core_api_client)
end
|
#repository_sync_url_class ⇒ Object
28
29
30
|
# File 'app/services/katello/pulp3/api/core.rb', line 28
def repository_sync_url_class
repository_type.repo_sync_url_class
end
|
#repository_version_hrefs(options = {}) ⇒ Object
178
179
180
|
# File 'app/services/katello/pulp3/api/core.rb', line 178
def repository_version_hrefs(options = {})
repository_versions(options).map(&:pulp_href).uniq
end
|
#repository_versions(options = {}) ⇒ Object
182
183
184
185
186
187
188
189
190
191
|
# File 'app/services/katello/pulp3/api/core.rb', line 182
def repository_versions(options = {})
current_pulp_repositories = self.list_all(options)
repo_hrefs = current_pulp_repositories.collect { |repo| repo.pulp_href }.uniq
version_hrefs = repo_hrefs.collect do |href|
versions_list_for_repository(href, options)
end
version_hrefs.flatten
end
|
#repository_versions_api ⇒ Object
66
67
68
|
# File 'app/services/katello/pulp3/api/core.rb', line 66
def repository_versions_api
repository_type.repository_versions_api_class.new(api_client)
end
|
#signing_services_api ⇒ Object
147
148
149
|
# File 'app/services/katello/pulp3/api/core.rb', line 147
def signing_services_api
PulpcoreClient::SigningServicesApi.new(core_api_client)
end
|
#task_groups_api ⇒ Object
155
156
157
|
# File 'app/services/katello/pulp3/api/core.rb', line 155
def task_groups_api
PulpcoreClient::TaskGroupsApi.new(core_api_client)
end
|
#tasks_api ⇒ Object
151
152
153
|
# File 'app/services/katello/pulp3/api/core.rb', line 151
def tasks_api
PulpcoreClient::TasksApi.new(core_api_client)
end
|
#upload_class ⇒ Object
159
160
161
|
# File 'app/services/katello/pulp3/api/core.rb', line 159
def upload_class
PulpcoreClient::Upload
end
|
#upload_commit_class ⇒ Object
143
144
145
|
# File 'app/services/katello/pulp3/api/core.rb', line 143
def upload_commit_class
PulpcoreClient::UploadCommit
end
|
#uploads_api ⇒ Object
139
140
141
|
# File 'app/services/katello/pulp3/api/core.rb', line 139
def uploads_api
PulpcoreClient::UploadsApi.new(core_api_client)
end
|
#versions_list_for_repository(repository_href, options) ⇒ Object
193
194
195
|
# File 'app/services/katello/pulp3/api/core.rb', line 193
def versions_list_for_repository(repository_href, options)
self.class.fetch_from_list { |page_opts| repository_versions_api.list(repository_href, page_opts.merge(options)) }
end
|
#yum_export_api ⇒ Object
108
109
110
|
# File 'app/services/katello/pulp3/api/core.rb', line 108
def yum_export_api
PulpcoreClient::ExportersFilesystemExportsApi.new(core_api_client)
end
|
#yum_exporter_api ⇒ Object
92
93
94
|
# File 'app/services/katello/pulp3/api/core.rb', line 92
def yum_exporter_api
PulpcoreClient::ExportersFilesystemApi.new(core_api_client)
end
|