pulp_ostree_client 2.0.0a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +174 -0
  4. data/Rakefile +10 -0
  5. data/docs/AsyncOperationResponse.md +17 -0
  6. data/docs/ContentCommitsApi.md +138 -0
  7. data/docs/ContentConfigsApi.md +138 -0
  8. data/docs/ContentObjectsApi.md +138 -0
  9. data/docs/ContentRefsApi.md +138 -0
  10. data/docs/ContentSummariesApi.md +138 -0
  11. data/docs/ContentSummary.md +21 -0
  12. data/docs/ContentSummaryResponse.md +21 -0
  13. data/docs/DistributionsOstreeApi.md +372 -0
  14. data/docs/OstreeOstreeCommitResponse.md +25 -0
  15. data/docs/OstreeOstreeConfigResponse.md +21 -0
  16. data/docs/OstreeOstreeDistribution.md +27 -0
  17. data/docs/OstreeOstreeDistributionResponse.md +33 -0
  18. data/docs/OstreeOstreeObjectResponse.md +27 -0
  19. data/docs/OstreeOstreeRefResponse.md +25 -0
  20. data/docs/OstreeOstreeRemote.md +59 -0
  21. data/docs/OstreeOstreeRemoteResponse.md +55 -0
  22. data/docs/OstreeOstreeRepository.md +25 -0
  23. data/docs/OstreeOstreeRepositoryResponse.md +33 -0
  24. data/docs/OstreeOstreeSummaryResponse.md +21 -0
  25. data/docs/OstreeRepoImport.md +23 -0
  26. data/docs/PaginatedRepositoryVersionResponseList.md +23 -0
  27. data/docs/PaginatedostreeOstreeCommitResponseList.md +23 -0
  28. data/docs/PaginatedostreeOstreeConfigResponseList.md +23 -0
  29. data/docs/PaginatedostreeOstreeDistributionResponseList.md +23 -0
  30. data/docs/PaginatedostreeOstreeObjectResponseList.md +23 -0
  31. data/docs/PaginatedostreeOstreeRefResponseList.md +23 -0
  32. data/docs/PaginatedostreeOstreeRemoteResponseList.md +23 -0
  33. data/docs/PaginatedostreeOstreeRepositoryResponseList.md +23 -0
  34. data/docs/PaginatedostreeOstreeSummaryResponseList.md +23 -0
  35. data/docs/PatchedostreeOstreeDistribution.md +27 -0
  36. data/docs/PatchedostreeOstreeRemote.md +59 -0
  37. data/docs/PatchedostreeOstreeRepository.md +25 -0
  38. data/docs/PolicyEnum.md +16 -0
  39. data/docs/RemotesOstreeApi.md +376 -0
  40. data/docs/RepositoriesOstreeApi.md +532 -0
  41. data/docs/RepositoriesOstreeVersionsApi.md +271 -0
  42. data/docs/RepositoryAddRemoveContent.md +21 -0
  43. data/docs/RepositorySyncURL.md +19 -0
  44. data/docs/RepositoryVersion.md +17 -0
  45. data/docs/RepositoryVersionResponse.md +27 -0
  46. data/git_push.sh +58 -0
  47. data/lib/pulp_ostree_client/api/content_commits_api.rb +170 -0
  48. data/lib/pulp_ostree_client/api/content_configs_api.rb +170 -0
  49. data/lib/pulp_ostree_client/api/content_objects_api.rb +170 -0
  50. data/lib/pulp_ostree_client/api/content_refs_api.rb +170 -0
  51. data/lib/pulp_ostree_client/api/content_summaries_api.rb +170 -0
  52. data/lib/pulp_ostree_client/api/distributions_ostree_api.rb +457 -0
  53. data/lib/pulp_ostree_client/api/remotes_ostree_api.rb +463 -0
  54. data/lib/pulp_ostree_client/api/repositories_ostree_api.rb +655 -0
  55. data/lib/pulp_ostree_client/api/repositories_ostree_versions_api.rb +339 -0
  56. data/lib/pulp_ostree_client/api_client.rb +406 -0
  57. data/lib/pulp_ostree_client/api_error.rb +57 -0
  58. data/lib/pulp_ostree_client/configuration.rb +250 -0
  59. data/lib/pulp_ostree_client/models/async_operation_response.rb +213 -0
  60. data/lib/pulp_ostree_client/models/content_summary.rb +246 -0
  61. data/lib/pulp_ostree_client/models/content_summary_response.rb +246 -0
  62. data/lib/pulp_ostree_client/models/ostree_ostree_commit_response.rb +256 -0
  63. data/lib/pulp_ostree_client/models/ostree_ostree_config_response.rb +232 -0
  64. data/lib/pulp_ostree_client/models/ostree_ostree_distribution.rb +270 -0
  65. data/lib/pulp_ostree_client/models/ostree_ostree_distribution_response.rb +299 -0
  66. data/lib/pulp_ostree_client/models/ostree_ostree_object_response.rb +275 -0
  67. data/lib/pulp_ostree_client/models/ostree_ostree_ref_response.rb +260 -0
  68. data/lib/pulp_ostree_client/models/ostree_ostree_remote.rb +536 -0
  69. data/lib/pulp_ostree_client/models/ostree_ostree_remote_response.rb +510 -0
  70. data/lib/pulp_ostree_client/models/ostree_ostree_repository.rb +270 -0
  71. data/lib/pulp_ostree_client/models/ostree_ostree_repository_response.rb +307 -0
  72. data/lib/pulp_ostree_client/models/ostree_ostree_summary_response.rb +232 -0
  73. data/lib/pulp_ostree_client/models/ostree_repo_import.rb +248 -0
  74. data/lib/pulp_ostree_client/models/paginated_repository_version_response_list.rb +237 -0
  75. data/lib/pulp_ostree_client/models/paginatedostree_ostree_commit_response_list.rb +237 -0
  76. data/lib/pulp_ostree_client/models/paginatedostree_ostree_config_response_list.rb +237 -0
  77. data/lib/pulp_ostree_client/models/paginatedostree_ostree_distribution_response_list.rb +237 -0
  78. data/lib/pulp_ostree_client/models/paginatedostree_ostree_object_response_list.rb +237 -0
  79. data/lib/pulp_ostree_client/models/paginatedostree_ostree_ref_response_list.rb +237 -0
  80. data/lib/pulp_ostree_client/models/paginatedostree_ostree_remote_response_list.rb +237 -0
  81. data/lib/pulp_ostree_client/models/paginatedostree_ostree_repository_response_list.rb +237 -0
  82. data/lib/pulp_ostree_client/models/paginatedostree_ostree_summary_response_list.rb +237 -0
  83. data/lib/pulp_ostree_client/models/patchedostree_ostree_distribution.rb +260 -0
  84. data/lib/pulp_ostree_client/models/patchedostree_ostree_remote.rb +526 -0
  85. data/lib/pulp_ostree_client/models/patchedostree_ostree_repository.rb +265 -0
  86. data/lib/pulp_ostree_client/models/policy_enum.rb +36 -0
  87. data/lib/pulp_ostree_client/models/repository_add_remove_content.rb +232 -0
  88. data/lib/pulp_ostree_client/models/repository_sync_url.rb +220 -0
  89. data/lib/pulp_ostree_client/models/repository_version.rb +208 -0
  90. data/lib/pulp_ostree_client/models/repository_version_response.rb +255 -0
  91. data/lib/pulp_ostree_client/version.rb +15 -0
  92. data/lib/pulp_ostree_client.rb +80 -0
  93. data/pulp_ostree_client.gemspec +39 -0
  94. data/spec/api/content_commits_api_spec.rb +68 -0
  95. data/spec/api/content_configs_api_spec.rb +68 -0
  96. data/spec/api/content_objects_api_spec.rb +68 -0
  97. data/spec/api/content_refs_api_spec.rb +68 -0
  98. data/spec/api/content_summaries_api_spec.rb +68 -0
  99. data/spec/api/distributions_ostree_api_spec.rb +125 -0
  100. data/spec/api/remotes_ostree_api_spec.rb +127 -0
  101. data/spec/api/repositories_ostree_api_spec.rb +160 -0
  102. data/spec/api/repositories_ostree_versions_api_spec.rb +104 -0
  103. data/spec/api_client_spec.rb +188 -0
  104. data/spec/configuration_spec.rb +42 -0
  105. data/spec/models/async_operation_response_spec.rb +41 -0
  106. data/spec/models/content_summary_response_spec.rb +53 -0
  107. data/spec/models/content_summary_spec.rb +53 -0
  108. data/spec/models/ostree_ostree_commit_response_spec.rb +65 -0
  109. data/spec/models/ostree_ostree_config_response_spec.rb +53 -0
  110. data/spec/models/ostree_ostree_distribution_response_spec.rb +89 -0
  111. data/spec/models/ostree_ostree_distribution_spec.rb +71 -0
  112. data/spec/models/ostree_ostree_object_response_spec.rb +71 -0
  113. data/spec/models/ostree_ostree_ref_response_spec.rb +65 -0
  114. data/spec/models/ostree_ostree_remote_response_spec.rb +155 -0
  115. data/spec/models/ostree_ostree_remote_spec.rb +167 -0
  116. data/spec/models/ostree_ostree_repository_response_spec.rb +89 -0
  117. data/spec/models/ostree_ostree_repository_spec.rb +65 -0
  118. data/spec/models/ostree_ostree_summary_response_spec.rb +53 -0
  119. data/spec/models/ostree_repo_import_spec.rb +59 -0
  120. data/spec/models/paginated_repository_version_response_list_spec.rb +59 -0
  121. data/spec/models/paginatedostree_ostree_commit_response_list_spec.rb +59 -0
  122. data/spec/models/paginatedostree_ostree_config_response_list_spec.rb +59 -0
  123. data/spec/models/paginatedostree_ostree_distribution_response_list_spec.rb +59 -0
  124. data/spec/models/paginatedostree_ostree_object_response_list_spec.rb +59 -0
  125. data/spec/models/paginatedostree_ostree_ref_response_list_spec.rb +59 -0
  126. data/spec/models/paginatedostree_ostree_remote_response_list_spec.rb +59 -0
  127. data/spec/models/paginatedostree_ostree_repository_response_list_spec.rb +59 -0
  128. data/spec/models/paginatedostree_ostree_summary_response_list_spec.rb +59 -0
  129. data/spec/models/patchedostree_ostree_distribution_spec.rb +71 -0
  130. data/spec/models/patchedostree_ostree_remote_spec.rb +167 -0
  131. data/spec/models/patchedostree_ostree_repository_spec.rb +65 -0
  132. data/spec/models/policy_enum_spec.rb +35 -0
  133. data/spec/models/repository_add_remove_content_spec.rb +53 -0
  134. data/spec/models/repository_sync_url_spec.rb +47 -0
  135. data/spec/models/repository_version_response_spec.rb +71 -0
  136. data/spec/models/repository_version_spec.rb +41 -0
  137. data/spec/spec_helper.rb +111 -0
  138. metadata +277 -0
@@ -0,0 +1,339 @@
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 'cgi'
14
+
15
+ module PulpOstreeClient
16
+ class RepositoriesOstreeVersionsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Delete a repository version
23
+ # Trigger an asynchronous task to delete a repository version.
24
+ # @param ostree_ostree_repository_version_href [String]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [AsyncOperationResponse]
27
+ def delete(ostree_ostree_repository_version_href, opts = {})
28
+ data, _status_code, _headers = delete_with_http_info(ostree_ostree_repository_version_href, opts)
29
+ data
30
+ end
31
+
32
+ # Delete a repository version
33
+ # Trigger an asynchronous task to delete a repository version.
34
+ # @param ostree_ostree_repository_version_href [String]
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(AsyncOperationResponse, Integer, Hash)>] AsyncOperationResponse data, response status code and response headers
37
+ def delete_with_http_info(ostree_ostree_repository_version_href, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: RepositoriesOstreeVersionsApi.delete ...'
40
+ end
41
+ # verify the required parameter 'ostree_ostree_repository_version_href' is set
42
+ if @api_client.config.client_side_validation && ostree_ostree_repository_version_href.nil?
43
+ fail ArgumentError, "Missing the required parameter 'ostree_ostree_repository_version_href' when calling RepositoriesOstreeVersionsApi.delete"
44
+ end
45
+ # resource path
46
+ local_var_path = '{ostree_ostree_repository_version_href}'.sub('{' + 'ostree_ostree_repository_version_href' + '}', CGI.escape(ostree_ostree_repository_version_href.to_s).gsub('%2F', '/'))
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
55
+
56
+ # form parameters
57
+ form_params = opts[:form_params] || {}
58
+
59
+ # http body (model)
60
+ post_body = opts[:body]
61
+
62
+ # return_type
63
+ return_type = opts[:return_type] || 'AsyncOperationResponse'
64
+
65
+ # auth_names
66
+ auth_names = opts[:auth_names] || ['basicAuth']
67
+
68
+ new_options = opts.merge(
69
+ :header_params => header_params,
70
+ :query_params => query_params,
71
+ :form_params => form_params,
72
+ :body => post_body,
73
+ :auth_names => auth_names,
74
+ :return_type => return_type
75
+ )
76
+
77
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
78
+ if @api_client.config.debugging
79
+ @api_client.config.logger.debug "API called: RepositoriesOstreeVersionsApi#delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
80
+ end
81
+ return data, status_code, headers
82
+ end
83
+
84
+ # List repository versions
85
+ # A ViewSet class that represents a single OSTree repository version.
86
+ # @param ostree_ostree_repository_href [String]
87
+ # @param [Hash] opts the optional parameters
88
+ # @option opts [String] :content Content Unit referenced by HREF
89
+ # @option opts [String] :content__in Content Unit referenced by HREF
90
+ # @option opts [Integer] :limit Number of results to return per page.
91
+ # @option opts [Integer] :number
92
+ # @option opts [Integer] :number__gt Filter results where number is greater than value
93
+ # @option opts [Integer] :number__gte Filter results where number is greater than or equal to value
94
+ # @option opts [Integer] :number__lt Filter results where number is less than value
95
+ # @option opts [Integer] :number__lte Filter results where number is less than or equal to value
96
+ # @option opts [Array<Integer>] :number__range Filter results where number is between two comma separated values
97
+ # @option opts [Integer] :offset The initial index from which to return the results.
98
+ # @option opts [String] :ordering Which field to use when ordering the results.
99
+ # @option opts [DateTime] :pulp_created ISO 8601 formatted dates are supported
100
+ # @option opts [DateTime] :pulp_created__gt Filter results where pulp_created is greater than value
101
+ # @option opts [DateTime] :pulp_created__gte Filter results where pulp_created is greater than or equal to value
102
+ # @option opts [DateTime] :pulp_created__lt Filter results where pulp_created is less than value
103
+ # @option opts [DateTime] :pulp_created__lte Filter results where pulp_created is less than or equal to value
104
+ # @option opts [Array<DateTime>] :pulp_created__range Filter results where pulp_created is between two comma separated values
105
+ # @option opts [String] :fields A list of fields to include in the response.
106
+ # @option opts [String] :exclude_fields A list of fields to exclude from the response.
107
+ # @return [PaginatedRepositoryVersionResponseList]
108
+ def list(ostree_ostree_repository_href, opts = {})
109
+ data, _status_code, _headers = list_with_http_info(ostree_ostree_repository_href, opts)
110
+ data
111
+ end
112
+
113
+ # List repository versions
114
+ # A ViewSet class that represents a single OSTree repository version.
115
+ # @param ostree_ostree_repository_href [String]
116
+ # @param [Hash] opts the optional parameters
117
+ # @option opts [String] :content Content Unit referenced by HREF
118
+ # @option opts [String] :content__in Content Unit referenced by HREF
119
+ # @option opts [Integer] :limit Number of results to return per page.
120
+ # @option opts [Integer] :number
121
+ # @option opts [Integer] :number__gt Filter results where number is greater than value
122
+ # @option opts [Integer] :number__gte Filter results where number is greater than or equal to value
123
+ # @option opts [Integer] :number__lt Filter results where number is less than value
124
+ # @option opts [Integer] :number__lte Filter results where number is less than or equal to value
125
+ # @option opts [Array<Integer>] :number__range Filter results where number is between two comma separated values
126
+ # @option opts [Integer] :offset The initial index from which to return the results.
127
+ # @option opts [String] :ordering Which field to use when ordering the results.
128
+ # @option opts [DateTime] :pulp_created ISO 8601 formatted dates are supported
129
+ # @option opts [DateTime] :pulp_created__gt Filter results where pulp_created is greater than value
130
+ # @option opts [DateTime] :pulp_created__gte Filter results where pulp_created is greater than or equal to value
131
+ # @option opts [DateTime] :pulp_created__lt Filter results where pulp_created is less than value
132
+ # @option opts [DateTime] :pulp_created__lte Filter results where pulp_created is less than or equal to value
133
+ # @option opts [Array<DateTime>] :pulp_created__range Filter results where pulp_created is between two comma separated values
134
+ # @option opts [String] :fields A list of fields to include in the response.
135
+ # @option opts [String] :exclude_fields A list of fields to exclude from the response.
136
+ # @return [Array<(PaginatedRepositoryVersionResponseList, Integer, Hash)>] PaginatedRepositoryVersionResponseList data, response status code and response headers
137
+ def list_with_http_info(ostree_ostree_repository_href, opts = {})
138
+ if @api_client.config.debugging
139
+ @api_client.config.logger.debug 'Calling API: RepositoriesOstreeVersionsApi.list ...'
140
+ end
141
+ # verify the required parameter 'ostree_ostree_repository_href' is set
142
+ if @api_client.config.client_side_validation && ostree_ostree_repository_href.nil?
143
+ fail ArgumentError, "Missing the required parameter 'ostree_ostree_repository_href' when calling RepositoriesOstreeVersionsApi.list"
144
+ end
145
+ # resource path
146
+ local_var_path = '{ostree_ostree_repository_href}versions/'.sub('{' + 'ostree_ostree_repository_href' + '}', CGI.escape(ostree_ostree_repository_href.to_s).gsub('%2F', '/'))
147
+
148
+ # query parameters
149
+ query_params = opts[:query_params] || {}
150
+ query_params[:'content'] = opts[:'content'] if !opts[:'content'].nil?
151
+ query_params[:'content__in'] = opts[:'content__in'] if !opts[:'content__in'].nil?
152
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
153
+ query_params[:'number'] = opts[:'number'] if !opts[:'number'].nil?
154
+ query_params[:'number__gt'] = opts[:'number__gt'] if !opts[:'number__gt'].nil?
155
+ query_params[:'number__gte'] = opts[:'number__gte'] if !opts[:'number__gte'].nil?
156
+ query_params[:'number__lt'] = opts[:'number__lt'] if !opts[:'number__lt'].nil?
157
+ query_params[:'number__lte'] = opts[:'number__lte'] if !opts[:'number__lte'].nil?
158
+ query_params[:'number__range'] = @api_client.build_collection_param(opts[:'number__range'], :csv) if !opts[:'number__range'].nil?
159
+ query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
160
+ query_params[:'ordering'] = opts[:'ordering'] if !opts[:'ordering'].nil?
161
+ query_params[:'pulp_created'] = opts[:'pulp_created'] if !opts[:'pulp_created'].nil?
162
+ query_params[:'pulp_created__gt'] = opts[:'pulp_created__gt'] if !opts[:'pulp_created__gt'].nil?
163
+ query_params[:'pulp_created__gte'] = opts[:'pulp_created__gte'] if !opts[:'pulp_created__gte'].nil?
164
+ query_params[:'pulp_created__lt'] = opts[:'pulp_created__lt'] if !opts[:'pulp_created__lt'].nil?
165
+ query_params[:'pulp_created__lte'] = opts[:'pulp_created__lte'] if !opts[:'pulp_created__lte'].nil?
166
+ query_params[:'pulp_created__range'] = @api_client.build_collection_param(opts[:'pulp_created__range'], :csv) if !opts[:'pulp_created__range'].nil?
167
+ query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
168
+ query_params[:'exclude_fields'] = opts[:'exclude_fields'] if !opts[:'exclude_fields'].nil?
169
+
170
+ # header parameters
171
+ header_params = opts[:header_params] || {}
172
+ # HTTP header 'Accept' (if needed)
173
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
174
+
175
+ # form parameters
176
+ form_params = opts[:form_params] || {}
177
+
178
+ # http body (model)
179
+ post_body = opts[:body]
180
+
181
+ # return_type
182
+ return_type = opts[:return_type] || 'PaginatedRepositoryVersionResponseList'
183
+
184
+ # auth_names
185
+ auth_names = opts[:auth_names] || ['basicAuth']
186
+
187
+ new_options = opts.merge(
188
+ :header_params => header_params,
189
+ :query_params => query_params,
190
+ :form_params => form_params,
191
+ :body => post_body,
192
+ :auth_names => auth_names,
193
+ :return_type => return_type
194
+ )
195
+
196
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
197
+ if @api_client.config.debugging
198
+ @api_client.config.logger.debug "API called: RepositoriesOstreeVersionsApi#list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
199
+ end
200
+ return data, status_code, headers
201
+ end
202
+
203
+ # Inspect a repository version
204
+ # A ViewSet class that represents a single OSTree repository version.
205
+ # @param ostree_ostree_repository_version_href [String]
206
+ # @param [Hash] opts the optional parameters
207
+ # @option opts [String] :fields A list of fields to include in the response.
208
+ # @option opts [String] :exclude_fields A list of fields to exclude from the response.
209
+ # @return [RepositoryVersionResponse]
210
+ def read(ostree_ostree_repository_version_href, opts = {})
211
+ data, _status_code, _headers = read_with_http_info(ostree_ostree_repository_version_href, opts)
212
+ data
213
+ end
214
+
215
+ # Inspect a repository version
216
+ # A ViewSet class that represents a single OSTree repository version.
217
+ # @param ostree_ostree_repository_version_href [String]
218
+ # @param [Hash] opts the optional parameters
219
+ # @option opts [String] :fields A list of fields to include in the response.
220
+ # @option opts [String] :exclude_fields A list of fields to exclude from the response.
221
+ # @return [Array<(RepositoryVersionResponse, Integer, Hash)>] RepositoryVersionResponse data, response status code and response headers
222
+ def read_with_http_info(ostree_ostree_repository_version_href, opts = {})
223
+ if @api_client.config.debugging
224
+ @api_client.config.logger.debug 'Calling API: RepositoriesOstreeVersionsApi.read ...'
225
+ end
226
+ # verify the required parameter 'ostree_ostree_repository_version_href' is set
227
+ if @api_client.config.client_side_validation && ostree_ostree_repository_version_href.nil?
228
+ fail ArgumentError, "Missing the required parameter 'ostree_ostree_repository_version_href' when calling RepositoriesOstreeVersionsApi.read"
229
+ end
230
+ # resource path
231
+ local_var_path = '{ostree_ostree_repository_version_href}'.sub('{' + 'ostree_ostree_repository_version_href' + '}', CGI.escape(ostree_ostree_repository_version_href.to_s).gsub('%2F', '/'))
232
+
233
+ # query parameters
234
+ query_params = opts[:query_params] || {}
235
+ query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
236
+ query_params[:'exclude_fields'] = opts[:'exclude_fields'] if !opts[:'exclude_fields'].nil?
237
+
238
+ # header parameters
239
+ header_params = opts[:header_params] || {}
240
+ # HTTP header 'Accept' (if needed)
241
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
242
+
243
+ # form parameters
244
+ form_params = opts[:form_params] || {}
245
+
246
+ # http body (model)
247
+ post_body = opts[:body]
248
+
249
+ # return_type
250
+ return_type = opts[:return_type] || 'RepositoryVersionResponse'
251
+
252
+ # auth_names
253
+ auth_names = opts[:auth_names] || ['basicAuth']
254
+
255
+ new_options = opts.merge(
256
+ :header_params => header_params,
257
+ :query_params => query_params,
258
+ :form_params => form_params,
259
+ :body => post_body,
260
+ :auth_names => auth_names,
261
+ :return_type => return_type
262
+ )
263
+
264
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
265
+ if @api_client.config.debugging
266
+ @api_client.config.logger.debug "API called: RepositoriesOstreeVersionsApi#read\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
267
+ end
268
+ return data, status_code, headers
269
+ end
270
+
271
+ # Trigger an asynchronous task to repair a repository version.
272
+ # @param ostree_ostree_repository_version_href [String]
273
+ # @param repository_version [RepositoryVersion]
274
+ # @param [Hash] opts the optional parameters
275
+ # @return [AsyncOperationResponse]
276
+ def repair(ostree_ostree_repository_version_href, repository_version, opts = {})
277
+ data, _status_code, _headers = repair_with_http_info(ostree_ostree_repository_version_href, repository_version, opts)
278
+ data
279
+ end
280
+
281
+ # Trigger an asynchronous task to repair a repository version.
282
+ # @param ostree_ostree_repository_version_href [String]
283
+ # @param repository_version [RepositoryVersion]
284
+ # @param [Hash] opts the optional parameters
285
+ # @return [Array<(AsyncOperationResponse, Integer, Hash)>] AsyncOperationResponse data, response status code and response headers
286
+ def repair_with_http_info(ostree_ostree_repository_version_href, repository_version, opts = {})
287
+ if @api_client.config.debugging
288
+ @api_client.config.logger.debug 'Calling API: RepositoriesOstreeVersionsApi.repair ...'
289
+ end
290
+ # verify the required parameter 'ostree_ostree_repository_version_href' is set
291
+ if @api_client.config.client_side_validation && ostree_ostree_repository_version_href.nil?
292
+ fail ArgumentError, "Missing the required parameter 'ostree_ostree_repository_version_href' when calling RepositoriesOstreeVersionsApi.repair"
293
+ end
294
+ # verify the required parameter 'repository_version' is set
295
+ if @api_client.config.client_side_validation && repository_version.nil?
296
+ fail ArgumentError, "Missing the required parameter 'repository_version' when calling RepositoriesOstreeVersionsApi.repair"
297
+ end
298
+ # resource path
299
+ local_var_path = '{ostree_ostree_repository_version_href}repair/'.sub('{' + 'ostree_ostree_repository_version_href' + '}', CGI.escape(ostree_ostree_repository_version_href.to_s).gsub('%2F', '/'))
300
+
301
+ # query parameters
302
+ query_params = opts[:query_params] || {}
303
+
304
+ # header parameters
305
+ header_params = opts[:header_params] || {}
306
+ # HTTP header 'Accept' (if needed)
307
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
308
+ # HTTP header 'Content-Type'
309
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded', 'multipart/form-data'])
310
+
311
+ # form parameters
312
+ form_params = opts[:form_params] || {}
313
+
314
+ # http body (model)
315
+ post_body = opts[:body] || @api_client.object_to_http_body(repository_version)
316
+
317
+ # return_type
318
+ return_type = opts[:return_type] || 'AsyncOperationResponse'
319
+
320
+ # auth_names
321
+ auth_names = opts[:auth_names] || ['basicAuth']
322
+
323
+ new_options = opts.merge(
324
+ :header_params => header_params,
325
+ :query_params => query_params,
326
+ :form_params => form_params,
327
+ :body => post_body,
328
+ :auth_names => auth_names,
329
+ :return_type => return_type
330
+ )
331
+
332
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
333
+ if @api_client.config.debugging
334
+ @api_client.config.logger.debug "API called: RepositoriesOstreeVersionsApi#repair\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
335
+ end
336
+ return data, status_code, headers
337
+ end
338
+ end
339
+ end
@@ -0,0 +1,406 @@
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
+ require 'json'
15
+ require 'logger'
16
+ require 'tempfile'
17
+ require 'faraday'
18
+
19
+ module PulpOstreeClient
20
+ class ApiClient
21
+ # The Configuration object holding settings to be used in the API client.
22
+ attr_accessor :config
23
+
24
+ # Defines the headers to be used in HTTP requests of all API calls by default.
25
+ #
26
+ # @return [Hash]
27
+ attr_accessor :default_headers
28
+
29
+ # Initializes the ApiClient
30
+ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
31
+ def initialize(config = Configuration.default)
32
+ @config = config
33
+ @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
34
+ @default_headers = {
35
+ 'Content-Type' => 'application/json',
36
+ 'User-Agent' => @user_agent
37
+ }
38
+ end
39
+
40
+ def self.default
41
+ @@default ||= ApiClient.new
42
+ end
43
+
44
+ # Call an API with given options.
45
+ #
46
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
47
+ # the data deserialized from response body (could be nil), response status code and response headers.
48
+ def call_api(http_method, path, opts = {})
49
+ ssl_options = {
50
+ :ca_file => @config.ssl_ca_file,
51
+ :verify => @config.ssl_verify,
52
+ :verify_mode => @config.ssl_verify_mode,
53
+ :client_cert => @config.ssl_client_cert,
54
+ :client_key => @config.ssl_client_key
55
+ }
56
+ request_options = {
57
+ :params_encoder => @config.params_encoder
58
+ }
59
+ connection = Faraday.new(:url => config.base_url, :ssl => ssl_options, :request => request_options) do |conn|
60
+ conn.basic_auth(config.username, config.password)
61
+ if opts[:header_params]["Content-Type"] == "multipart/form-data"
62
+ conn.request :multipart
63
+ conn.request :url_encoded
64
+ end
65
+ conn.adapter(Faraday.default_adapter)
66
+ end
67
+
68
+ begin
69
+ response = connection.public_send(http_method.to_sym.downcase) do |req|
70
+ build_request(http_method, path, req, opts)
71
+ end
72
+
73
+ if @config.debugging
74
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
75
+ end
76
+
77
+ unless response.success?
78
+ if response.status == 0
79
+ # Errors from libcurl will be made visible here
80
+ fail ApiError.new(:code => 0,
81
+ :message => response.return_message)
82
+ else
83
+ fail ApiError.new(:code => response.status,
84
+ :response_headers => response.headers,
85
+ :response_body => response.body),
86
+ response.reason_phrase
87
+ end
88
+ end
89
+ rescue Faraday::TimeoutError
90
+ fail ApiError.new('Connection timed out')
91
+ end
92
+
93
+ if opts[:return_type]
94
+ data = deserialize(response, opts[:return_type])
95
+ else
96
+ data = nil
97
+ end
98
+ return data, response.status, response.headers
99
+ end
100
+
101
+ # Builds the HTTP request
102
+ #
103
+ # @param [String] http_method HTTP method/verb (e.g. POST)
104
+ # @param [String] path URL path (e.g. /account/new)
105
+ # @option opts [Hash] :header_params Header parameters
106
+ # @option opts [Hash] :query_params Query parameters
107
+ # @option opts [Hash] :form_params Query parameters
108
+ # @option opts [Object] :body HTTP body (JSON/XML)
109
+ # @return [Typhoeus::Request] A Typhoeus Request
110
+ def build_request(http_method, path, request, opts = {})
111
+ url = build_request_url(path)
112
+ http_method = http_method.to_sym.downcase
113
+
114
+ header_params = @default_headers.merge(opts[:header_params] || {})
115
+ query_params = opts[:query_params] || {}
116
+ form_params = opts[:form_params] || {}
117
+
118
+ update_params_for_auth! header_params, query_params, opts[:auth_names]
119
+
120
+ req_opts = {
121
+ :method => http_method,
122
+ :headers => header_params,
123
+ :params => query_params,
124
+ :params_encoding => @config.params_encoding,
125
+ :timeout => @config.timeout,
126
+ :verbose => @config.debugging
127
+ }
128
+
129
+ if [:post, :patch, :put, :delete].include?(http_method)
130
+ req_body = build_request_body(header_params, form_params, opts[:body])
131
+ req_opts.update :body => req_body
132
+ if @config.debugging
133
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
134
+ end
135
+ end
136
+ request.headers = header_params
137
+ request.body = req_body
138
+ request.url url
139
+ request.params = query_params
140
+ download_file(request) if opts[:return_type] == 'File'
141
+ request
142
+ end
143
+
144
+ # Builds the HTTP request body
145
+ #
146
+ # @param [Hash] header_params Header parameters
147
+ # @param [Hash] form_params Query parameters
148
+ # @param [Object] body HTTP body (JSON/XML)
149
+ # @return [String] HTTP body data in the form of string
150
+ def build_request_body(header_params, form_params, body)
151
+ # http form
152
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
153
+ data = URI.encode_www_form(form_params)
154
+ elsif header_params['Content-Type'] == 'multipart/form-data'
155
+ data = {}
156
+ form_params.each do |key, value|
157
+ case value
158
+ when ::File, ::Tempfile
159
+ # TODO hardcode to application/octet-stream, need better way to detect content type
160
+ data[key] = Faraday::UploadIO.new(value.path, 'application/octet-stream', value.path)
161
+ when ::Array, nil
162
+ # let Faraday handle Array and nil parameters
163
+ data[key] = value
164
+ else
165
+ data[key] = value.to_s
166
+ end
167
+ end
168
+ elsif body
169
+ data = body.is_a?(String) ? body : body.to_json
170
+ else
171
+ data = nil
172
+ end
173
+ data
174
+ end
175
+
176
+ # Check if the given MIME is a JSON MIME.
177
+ # JSON MIME examples:
178
+ # application/json
179
+ # application/json; charset=UTF8
180
+ # APPLICATION/JSON
181
+ # */*
182
+ # @param [String] mime MIME
183
+ # @return [Boolean] True if the MIME is application/json
184
+ def json_mime?(mime)
185
+ (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
186
+ end
187
+
188
+ # Deserialize the response to the given return type.
189
+ #
190
+ # @param [Response] response HTTP response
191
+ # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
192
+ def deserialize(response, return_type)
193
+ body = response.body
194
+
195
+ # handle file downloading - return the File instance processed in request callbacks
196
+ # note that response body is empty when the file is written in chunks in request on_body callback
197
+ return @tempfile if return_type == 'File'
198
+
199
+ return nil if body.nil? || body.empty?
200
+
201
+ # return response body directly for String return type
202
+ return body if return_type == 'String'
203
+
204
+ # ensuring a default content type
205
+ content_type = response.headers['Content-Type'] || 'application/json'
206
+
207
+ fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
208
+
209
+ begin
210
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
211
+ rescue JSON::ParserError => e
212
+ if %w(String Date DateTime).include?(return_type)
213
+ data = body
214
+ else
215
+ raise e
216
+ end
217
+ end
218
+
219
+ convert_to_type data, return_type
220
+ end
221
+
222
+ # Convert data to the given return type.
223
+ # @param [Object] data Data to be converted
224
+ # @param [String] return_type Return type
225
+ # @return [Mixed] Data in a particular type
226
+ def convert_to_type(data, return_type)
227
+ return nil if data.nil?
228
+ case return_type
229
+ when 'String'
230
+ data.to_s
231
+ when 'Integer'
232
+ data.to_i
233
+ when 'Float'
234
+ data.to_f
235
+ when 'Boolean'
236
+ data == true
237
+ when 'DateTime'
238
+ # parse date time (expecting ISO 8601 format)
239
+ DateTime.parse data
240
+ when 'Date'
241
+ # parse date time (expecting ISO 8601 format)
242
+ Date.parse data
243
+ when 'Object'
244
+ # generic object (usually a Hash), return directly
245
+ data
246
+ when /\AArray<(.+)>\z/
247
+ # e.g. Array<Pet>
248
+ sub_type = $1
249
+ data.map { |item| convert_to_type(item, sub_type) }
250
+ when /\AHash\<String, (.+)\>\z/
251
+ # e.g. Hash<String, Integer>
252
+ sub_type = $1
253
+ {}.tap do |hash|
254
+ data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
255
+ end
256
+ else
257
+ # models, e.g. Pet
258
+ PulpOstreeClient.const_get(return_type).build_from_hash(data)
259
+ end
260
+ end
261
+
262
+ # Save response body into a file in (the defined) temporary folder, using the filename
263
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
264
+ # The response body is written to the file in chunks in order to handle files which
265
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
266
+ # process can use.
267
+ #
268
+ # @see Configuration#temp_folder_path
269
+ def download_file(request)
270
+ tempfile = nil
271
+ encoding = nil
272
+ request.on_headers do |response|
273
+ content_disposition = response.headers['Content-Disposition']
274
+ if content_disposition && content_disposition =~ /filename=/i
275
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
276
+ prefix = sanitize_filename(filename)
277
+ else
278
+ prefix = 'download-'
279
+ end
280
+ prefix = prefix + '-' unless prefix.end_with?('-')
281
+ encoding = response.body.encoding
282
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
283
+ @tempfile = tempfile
284
+ end
285
+ request.on_body do |chunk|
286
+ chunk.force_encoding(encoding)
287
+ tempfile.write(chunk)
288
+ end
289
+ request.on_complete do |response|
290
+ if tempfile
291
+ tempfile.close
292
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
293
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
294
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
295
+ "explicitly with `tempfile.delete`"
296
+ end
297
+ end
298
+ end
299
+
300
+ # Sanitize filename by removing path.
301
+ # e.g. ../../sun.gif becomes sun.gif
302
+ #
303
+ # @param [String] filename the filename to be sanitized
304
+ # @return [String] the sanitized filename
305
+ def sanitize_filename(filename)
306
+ filename.gsub(/.*[\/\\]/, '')
307
+ end
308
+
309
+ def build_request_url(path)
310
+ # Add leading and trailing slashes to path
311
+ path = "/#{path}".gsub(/\/+/, '/')
312
+ @config.base_url + path
313
+ end
314
+
315
+ # Update hearder and query params based on authentication settings.
316
+ #
317
+ # @param [Hash] header_params Header parameters
318
+ # @param [Hash] query_params Query parameters
319
+ # @param [String] auth_names Authentication scheme name
320
+ def update_params_for_auth!(header_params, query_params, auth_names)
321
+ Array(auth_names).each do |auth_name|
322
+ auth_setting = @config.auth_settings[auth_name]
323
+ next unless auth_setting
324
+ case auth_setting[:in]
325
+ when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
326
+ when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
327
+ else fail ArgumentError, 'Authentication token must be in `query` of `header`'
328
+ end
329
+ end
330
+ end
331
+
332
+ # Sets user agent in HTTP header
333
+ #
334
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
335
+ def user_agent=(user_agent)
336
+ @user_agent = user_agent
337
+ @default_headers['User-Agent'] = @user_agent
338
+ end
339
+
340
+ # Return Accept header based on an array of accepts provided.
341
+ # @param [Array] accepts array for Accept
342
+ # @return [String] the Accept header (e.g. application/json)
343
+ def select_header_accept(accepts)
344
+ return nil if accepts.nil? || accepts.empty?
345
+ # use JSON when present, otherwise use all of the provided
346
+ json_accept = accepts.find { |s| json_mime?(s) }
347
+ json_accept || accepts.join(',')
348
+ end
349
+
350
+ # Return Content-Type header based on an array of content types provided.
351
+ # @param [Array] content_types array for Content-Type
352
+ # @return [String] the Content-Type header (e.g. application/json)
353
+ def select_header_content_type(content_types)
354
+ # use application/json by default
355
+ return 'application/json' if content_types.nil? || content_types.empty?
356
+ # use JSON when present, otherwise use the first one
357
+ json_content_type = content_types.find { |s| json_mime?(s) }
358
+ json_content_type || content_types.first
359
+ end
360
+
361
+ # Convert object (array, hash, object, etc) to JSON string.
362
+ # @param [Object] model object to be converted into JSON string
363
+ # @return [String] JSON string representation of the object
364
+ def object_to_http_body(model)
365
+ return model if model.nil? || model.is_a?(String)
366
+ local_body = nil
367
+ if model.is_a?(Array)
368
+ local_body = model.map { |m| object_to_hash(m) }
369
+ else
370
+ local_body = object_to_hash(model)
371
+ end
372
+ local_body.to_json
373
+ end
374
+
375
+ # Convert object(non-array) to hash.
376
+ # @param [Object] obj object to be converted into JSON string
377
+ # @return [String] JSON string representation of the object
378
+ def object_to_hash(obj)
379
+ if obj.respond_to?(:to_hash)
380
+ obj.to_hash
381
+ else
382
+ obj
383
+ end
384
+ end
385
+
386
+ # Build parameter value according to the given collection format.
387
+ # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
388
+ def build_collection_param(param, collection_format)
389
+ case collection_format
390
+ when :csv
391
+ param.join(',')
392
+ when :ssv
393
+ param.join(' ')
394
+ when :tsv
395
+ param.join("\t")
396
+ when :pipes
397
+ param.join('|')
398
+ when :multi
399
+ # return the array directly as typhoeus will handle it as expected
400
+ param
401
+ else
402
+ fail "unknown collection format: #{collection_format.inspect}"
403
+ end
404
+ end
405
+ end
406
+ end