swaggy_jenkins 0.0.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +3 -1
- data/Gemfile.lock +51 -50
- data/README.md +25 -33
- data/Rakefile +2 -0
- data/bin/bundle +114 -0
- data/bin/byebug +29 -0
- data/bin/coderay +29 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/pry +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/bin/ruby-parse +29 -0
- data/bin/ruby-rewrite +29 -0
- data/docs/AllView.md +17 -5
- data/docs/BaseApi.md +75 -0
- data/docs/BlueOceanApi.md +1347 -631
- data/docs/BranchImpl.md +37 -15
- data/docs/BranchImpllinks.md +21 -7
- data/docs/BranchImplpermissions.md +21 -7
- data/docs/CauseAction.md +15 -4
- data/docs/CauseUserIdCause.md +19 -6
- data/docs/ClassesByClass.md +15 -4
- data/docs/ClockDifference.md +15 -4
- data/docs/ComputerSet.md +21 -7
- data/docs/DefaultCrumbIssuer.md +17 -5
- data/docs/DiskSpaceMonitorDescriptorDiskSpace.md +19 -6
- data/docs/EmptyChangeLogSet.md +15 -4
- data/docs/ExtensionClassContainerImpl1.md +17 -5
- data/docs/ExtensionClassContainerImpl1links.md +15 -4
- data/docs/ExtensionClassContainerImpl1map.md +17 -5
- data/docs/ExtensionClassImpl.md +17 -5
- data/docs/ExtensionClassImpllinks.md +15 -4
- data/docs/FavoriteImpl.md +17 -5
- data/docs/FavoriteImpllinks.md +15 -4
- data/docs/FreeStyleBuild.md +47 -20
- data/docs/FreeStyleProject.md +65 -29
- data/docs/FreeStyleProjectactions.md +13 -3
- data/docs/FreeStyleProjecthealthReport.md +21 -7
- data/docs/GenericResource.md +23 -8
- data/docs/GithubContent.md +27 -10
- data/docs/GithubFile.md +15 -4
- data/docs/GithubOrganization.md +19 -6
- data/docs/GithubOrganizationlinks.md +17 -5
- data/docs/GithubRepositories.md +23 -8
- data/docs/GithubRepositorieslinks.md +15 -4
- data/docs/GithubRepository.md +27 -10
- data/docs/GithubRepositorylinks.md +15 -4
- data/docs/GithubRepositorypermissions.md +19 -6
- data/docs/GithubRespositoryContainer.md +17 -5
- data/docs/GithubRespositoryContainerlinks.md +15 -4
- data/docs/GithubScm.md +21 -7
- data/docs/GithubScmlinks.md +15 -4
- data/docs/Hudson.md +41 -17
- data/docs/HudsonMasterComputer.md +43 -18
- data/docs/HudsonMasterComputerexecutors.md +23 -8
- data/docs/HudsonMasterComputermonitorData.md +25 -9
- data/docs/HudsonassignedLabels.md +13 -3
- data/docs/InputStepImpl.md +25 -9
- data/docs/InputStepImpllinks.md +15 -4
- data/docs/Label1.md +13 -3
- data/docs/Link.md +15 -4
- data/docs/ListView.md +21 -7
- data/docs/MultibranchPipeline.md +39 -16
- data/docs/NullSCM.md +13 -3
- data/docs/Organisation.md +15 -4
- data/docs/Pipeline.md +27 -10
- data/docs/PipelineActivity.md +41 -17
- data/docs/PipelineActivityartifacts.md +19 -6
- data/docs/PipelineBranchesitem.md +29 -11
- data/docs/PipelineBranchesitemlatestRun.md +39 -16
- data/docs/PipelineBranchesitempullRequest.md +23 -8
- data/docs/PipelineBranchesitempullRequestlinks.md +15 -4
- data/docs/PipelineFolderImpl.md +25 -9
- data/docs/PipelineImpl.md +29 -11
- data/docs/PipelineImpllinks.md +21 -7
- data/docs/PipelineRun.md +41 -17
- data/docs/PipelineRunImpl.md +41 -17
- data/docs/PipelineRunImpllinks.md +23 -8
- data/docs/PipelineRunNode.md +27 -10
- data/docs/PipelineRunNodeedges.md +15 -4
- data/docs/PipelineRunartifacts.md +19 -6
- data/docs/PipelineStepImpl.md +29 -11
- data/docs/PipelineStepImpllinks.md +17 -5
- data/docs/PipelinelatestRun.md +41 -17
- data/docs/PipelinelatestRunartifacts.md +19 -6
- data/docs/Queue.md +15 -4
- data/docs/QueueBlockedItem.md +35 -14
- data/docs/QueueItemImpl.md +21 -7
- data/docs/QueueLeftItem.md +37 -15
- data/docs/RemoteAccessApi.md +666 -350
- data/docs/ResponseTimeMonitorData.md +17 -5
- data/docs/StringParameterDefinition.md +21 -7
- data/docs/StringParameterValue.md +17 -5
- data/docs/SwapSpaceMonitorMemoryUsage2.md +21 -7
- data/docs/UnlabeledLoadStatistics.md +13 -3
- data/docs/User.md +21 -7
- data/git_push.sh +12 -10
- data/lib/swaggy_jenkins/api/base_api.rb +77 -0
- data/lib/swaggy_jenkins/api/blue_ocean_api.rb +1048 -643
- data/lib/swaggy_jenkins/api/remote_access_api.rb +506 -361
- data/lib/swaggy_jenkins/api_client.rb +95 -94
- data/lib/swaggy_jenkins/api_error.rb +22 -3
- data/lib/swaggy_jenkins/configuration.rb +91 -15
- data/lib/swaggy_jenkins/models/all_view.rb +59 -29
- data/lib/swaggy_jenkins/models/branch_impl.rb +76 -46
- data/lib/swaggy_jenkins/models/branch_impllinks.rb +62 -32
- data/lib/swaggy_jenkins/models/branch_implpermissions.rb +65 -35
- data/lib/swaggy_jenkins/models/cause_action.rb +58 -28
- data/lib/swaggy_jenkins/models/cause_user_id_cause.rb +63 -33
- data/lib/swaggy_jenkins/models/classes_by_class.rb +58 -28
- data/lib/swaggy_jenkins/models/clock_difference.rb +58 -28
- data/lib/swaggy_jenkins/models/computer_set.rb +64 -34
- data/lib/swaggy_jenkins/models/default_crumb_issuer.rb +60 -30
- data/lib/swaggy_jenkins/models/disk_space_monitor_descriptor_disk_space.rb +60 -30
- data/lib/swaggy_jenkins/models/empty_change_log_set.rb +58 -28
- data/lib/swaggy_jenkins/models/extension_class_container_impl1.rb +59 -29
- data/lib/swaggy_jenkins/models/extension_class_container_impl1links.rb +59 -29
- data/lib/swaggy_jenkins/models/extension_class_container_impl1map.rb +61 -31
- data/lib/swaggy_jenkins/models/extension_class_impl.rb +59 -29
- data/lib/swaggy_jenkins/models/extension_class_impllinks.rb +59 -29
- data/lib/swaggy_jenkins/models/favorite_impl.rb +59 -29
- data/lib/swaggy_jenkins/models/favorite_impllinks.rb +59 -29
- data/lib/swaggy_jenkins/models/free_style_build.rb +83 -53
- data/lib/swaggy_jenkins/models/free_style_project.rb +105 -75
- data/lib/swaggy_jenkins/models/free_style_projectactions.rb +57 -27
- data/lib/swaggy_jenkins/models/free_style_projecthealth_report.rb +63 -33
- data/lib/swaggy_jenkins/models/generic_resource.rb +65 -35
- data/lib/swaggy_jenkins/models/github_content.rb +65 -35
- data/lib/swaggy_jenkins/models/github_file.rb +58 -28
- data/lib/swaggy_jenkins/models/github_organization.rb +62 -32
- data/lib/swaggy_jenkins/models/github_organizationlinks.rb +60 -30
- data/lib/swaggy_jenkins/models/github_repositories.rb +65 -35
- data/lib/swaggy_jenkins/models/github_repositorieslinks.rb +59 -29
- data/lib/swaggy_jenkins/models/github_repository.rb +67 -37
- data/lib/swaggy_jenkins/models/github_repositorylinks.rb +59 -29
- data/lib/swaggy_jenkins/models/github_repositorypermissions.rb +63 -33
- data/lib/swaggy_jenkins/models/github_respository_container.rb +59 -29
- data/lib/swaggy_jenkins/models/github_respository_containerlinks.rb +59 -29
- data/lib/swaggy_jenkins/models/github_scm.rb +62 -32
- data/lib/swaggy_jenkins/models/github_scmlinks.rb +59 -29
- data/lib/swaggy_jenkins/models/hudson.rb +84 -54
- data/lib/swaggy_jenkins/models/hudson_master_computer.rb +89 -59
- data/lib/swaggy_jenkins/models/hudson_master_computerexecutors.rb +66 -36
- data/lib/swaggy_jenkins/models/hudson_master_computermonitor_data.rb +69 -39
- data/lib/swaggy_jenkins/models/hudsonassigned_labels.rb +57 -27
- data/lib/swaggy_jenkins/models/input_step_impl.rb +63 -33
- data/lib/swaggy_jenkins/models/input_step_impllinks.rb +59 -29
- data/lib/swaggy_jenkins/models/label1.rb +57 -27
- data/lib/swaggy_jenkins/models/link.rb +58 -28
- data/lib/swaggy_jenkins/models/list_view.rb +61 -31
- data/lib/swaggy_jenkins/models/multibranch_pipeline.rb +81 -51
- data/lib/swaggy_jenkins/models/null_scm.rb +57 -27
- data/lib/swaggy_jenkins/models/organisation.rb +58 -28
- data/lib/swaggy_jenkins/models/pipeline.rb +69 -39
- data/lib/swaggy_jenkins/models/pipeline_activity.rb +78 -48
- data/lib/swaggy_jenkins/models/pipeline_activityartifacts.rb +60 -30
- data/lib/swaggy_jenkins/models/pipeline_branchesitem.rb +71 -41
- data/lib/swaggy_jenkins/models/pipeline_branchesitemlatest_run.rb +77 -47
- data/lib/swaggy_jenkins/models/pipeline_branchesitempull_request.rb +62 -32
- data/lib/swaggy_jenkins/models/pipeline_branchesitempull_requestlinks.rb +59 -29
- data/lib/swaggy_jenkins/models/pipeline_folder_impl.rb +67 -37
- data/lib/swaggy_jenkins/models/pipeline_impl.rb +70 -40
- data/lib/swaggy_jenkins/models/pipeline_impllinks.rb +62 -32
- data/lib/swaggy_jenkins/models/pipeline_run.rb +78 -48
- data/lib/swaggy_jenkins/models/pipeline_run_impl.rb +78 -48
- data/lib/swaggy_jenkins/models/pipeline_run_impllinks.rb +63 -33
- data/lib/swaggy_jenkins/models/pipeline_run_node.rb +67 -37
- data/lib/swaggy_jenkins/models/pipeline_run_nodeedges.rb +58 -28
- data/lib/swaggy_jenkins/models/pipeline_runartifacts.rb +60 -30
- data/lib/swaggy_jenkins/models/pipeline_step_impl.rb +68 -38
- data/lib/swaggy_jenkins/models/pipeline_step_impllinks.rb +60 -30
- data/lib/swaggy_jenkins/models/pipelinelatest_run.rb +78 -48
- data/lib/swaggy_jenkins/models/pipelinelatest_runartifacts.rb +60 -30
- data/lib/swaggy_jenkins/models/queue.rb +58 -28
- data/lib/swaggy_jenkins/models/queue_blocked_item.rb +73 -43
- data/lib/swaggy_jenkins/models/queue_item_impl.rb +63 -33
- data/lib/swaggy_jenkins/models/queue_left_item.rb +74 -44
- data/lib/swaggy_jenkins/models/response_time_monitor_data.rb +59 -29
- data/lib/swaggy_jenkins/models/string_parameter_definition.rb +62 -32
- data/lib/swaggy_jenkins/models/string_parameter_value.rb +59 -29
- data/lib/swaggy_jenkins/models/swap_space_monitor_memory_usage2.rb +65 -35
- data/lib/swaggy_jenkins/models/unlabeled_load_statistics.rb +57 -27
- data/lib/swaggy_jenkins/models/user.rb +62 -32
- data/lib/swaggy_jenkins/version.rb +4 -4
- data/lib/swaggy_jenkins.rb +4 -16
- data/spec/api/base_api_spec.rb +45 -0
- data/spec/api/blue_ocean_api_spec.rb +76 -88
- data/spec/api/remote_access_api_spec.rb +28 -59
- data/spec/api_client_spec.rb +40 -40
- data/spec/configuration_spec.rb +11 -11
- data/spec/models/all_view_spec.rb +10 -18
- data/spec/models/branch_impl_spec.rb +20 -28
- data/spec/models/branch_impllinks_spec.rb +12 -20
- data/spec/models/branch_implpermissions_spec.rb +12 -20
- data/spec/models/cause_action_spec.rb +9 -17
- data/spec/models/cause_user_id_cause_spec.rb +11 -19
- data/spec/models/classes_by_class_spec.rb +9 -17
- data/spec/models/clock_difference_spec.rb +9 -17
- data/spec/models/computer_set_spec.rb +12 -20
- data/spec/models/default_crumb_issuer_spec.rb +10 -18
- data/spec/models/disk_space_monitor_descriptor_disk_space_spec.rb +11 -19
- data/spec/models/empty_change_log_set_spec.rb +9 -17
- data/spec/models/extension_class_container_impl1_spec.rb +10 -18
- data/spec/models/extension_class_container_impl1links_spec.rb +9 -17
- data/spec/models/extension_class_container_impl1map_spec.rb +10 -18
- data/spec/models/extension_class_impl_spec.rb +10 -18
- data/spec/models/extension_class_impllinks_spec.rb +9 -17
- data/spec/models/favorite_impl_spec.rb +10 -18
- data/spec/models/favorite_impllinks_spec.rb +9 -17
- data/spec/models/free_style_build_spec.rb +25 -33
- data/spec/models/free_style_project_spec.rb +34 -42
- data/spec/models/free_style_projectactions_spec.rb +8 -16
- data/spec/models/free_style_projecthealth_report_spec.rb +12 -20
- data/spec/models/generic_resource_spec.rb +13 -21
- data/spec/models/github_content_spec.rb +15 -23
- data/spec/models/github_file_spec.rb +9 -17
- data/spec/models/github_organization_spec.rb +11 -19
- data/spec/models/github_organizationlinks_spec.rb +10 -18
- data/spec/models/github_repositories_spec.rb +13 -21
- data/spec/models/github_repositorieslinks_spec.rb +9 -17
- data/spec/models/github_repository_spec.rb +15 -23
- data/spec/models/github_repositorylinks_spec.rb +9 -17
- data/spec/models/github_repositorypermissions_spec.rb +11 -19
- data/spec/models/github_respository_container_spec.rb +10 -18
- data/spec/models/github_respository_containerlinks_spec.rb +9 -17
- data/spec/models/github_scm_spec.rb +12 -20
- data/spec/models/github_scmlinks_spec.rb +9 -17
- data/spec/models/hudson_master_computer_spec.rb +23 -31
- data/spec/models/hudson_master_computerexecutors_spec.rb +13 -21
- data/spec/models/hudson_master_computermonitor_data_spec.rb +14 -22
- data/spec/models/hudson_spec.rb +22 -30
- data/spec/models/hudsonassigned_labels_spec.rb +8 -16
- data/spec/models/input_step_impl_spec.rb +14 -22
- data/spec/models/input_step_impllinks_spec.rb +9 -17
- data/spec/models/label1_spec.rb +8 -16
- data/spec/models/link_spec.rb +9 -17
- data/spec/models/list_view_spec.rb +12 -20
- data/spec/models/multibranch_pipeline_spec.rb +21 -29
- data/spec/models/null_scm_spec.rb +8 -16
- data/spec/models/organisation_spec.rb +9 -17
- data/spec/models/pipeline_activity_spec.rb +22 -30
- data/spec/models/pipeline_activityartifacts_spec.rb +11 -19
- data/spec/models/pipeline_branchesitem_spec.rb +16 -24
- data/spec/models/pipeline_branchesitemlatest_run_spec.rb +21 -29
- data/spec/models/pipeline_branchesitempull_request_spec.rb +13 -21
- data/spec/models/pipeline_branchesitempull_requestlinks_spec.rb +9 -17
- data/spec/models/pipeline_folder_impl_spec.rb +14 -22
- data/spec/models/pipeline_impl_spec.rb +16 -24
- data/spec/models/pipeline_impllinks_spec.rb +12 -20
- data/spec/models/pipeline_run_impl_spec.rb +22 -30
- data/spec/models/pipeline_run_impllinks_spec.rb +13 -21
- data/spec/models/pipeline_run_node_spec.rb +15 -23
- data/spec/models/pipeline_run_nodeedges_spec.rb +9 -17
- data/spec/models/pipeline_run_spec.rb +22 -30
- data/spec/models/pipeline_runartifacts_spec.rb +11 -19
- data/spec/models/pipeline_spec.rb +15 -23
- data/spec/models/pipeline_step_impl_spec.rb +16 -24
- data/spec/models/pipeline_step_impllinks_spec.rb +10 -18
- data/spec/models/pipelinelatest_run_spec.rb +22 -30
- data/spec/models/pipelinelatest_runartifacts_spec.rb +11 -19
- data/spec/models/queue_blocked_item_spec.rb +19 -27
- data/spec/models/queue_item_impl_spec.rb +12 -20
- data/spec/models/queue_left_item_spec.rb +20 -28
- data/spec/models/queue_spec.rb +9 -17
- data/spec/models/response_time_monitor_data_spec.rb +10 -18
- data/spec/models/string_parameter_definition_spec.rb +12 -20
- data/spec/models/string_parameter_value_spec.rb +10 -18
- data/spec/models/swap_space_monitor_memory_usage2_spec.rb +12 -20
- data/spec/models/unlabeled_load_statistics_spec.rb +8 -16
- data/spec/models/user_spec.rb +12 -20
- data/spec/spec_helper.rb +3 -3
- data/swaggy_jenkins.gemspec +6 -13
- metadata +97 -275
- data/docs/Body.md +0 -8
- data/docs/Organisations.md +0 -7
- data/docs/PipelineActivities.md +0 -7
- data/docs/PipelineBranches.md +0 -7
- data/docs/PipelineQueue.md +0 -7
- data/docs/PipelineRunNodeSteps.md +0 -7
- data/docs/PipelineRunNodes.md +0 -7
- data/docs/PipelineRunSteps.md +0 -7
- data/docs/PipelineRuns.md +0 -7
- data/docs/Pipelines.md +0 -7
- data/docs/ScmOrganisations.md +0 -7
- data/docs/UserFavorites.md +0 -7
- data/docs/Users.md +0 -7
- data/lib/swaggy_jenkins/models/body.rb +0 -193
- data/lib/swaggy_jenkins/models/organisations.rb +0 -179
- data/lib/swaggy_jenkins/models/pipeline_activities.rb +0 -179
- data/lib/swaggy_jenkins/models/pipeline_branches.rb +0 -179
- data/lib/swaggy_jenkins/models/pipeline_queue.rb +0 -179
- data/lib/swaggy_jenkins/models/pipeline_run_node_steps.rb +0 -179
- data/lib/swaggy_jenkins/models/pipeline_run_nodes.rb +0 -179
- data/lib/swaggy_jenkins/models/pipeline_run_steps.rb +0 -179
- data/lib/swaggy_jenkins/models/pipeline_runs.rb +0 -179
- data/lib/swaggy_jenkins/models/pipelines.rb +0 -179
- data/lib/swaggy_jenkins/models/scm_organisations.rb +0 -179
- data/lib/swaggy_jenkins/models/user_favorites.rb +0 -179
- data/lib/swaggy_jenkins/models/users.rb +0 -179
- data/spec/models/body_spec.rb +0 -42
- data/spec/models/organisations_spec.rb +0 -36
- data/spec/models/pipeline_activities_spec.rb +0 -36
- data/spec/models/pipeline_branches_spec.rb +0 -36
- data/spec/models/pipeline_queue_spec.rb +0 -36
- data/spec/models/pipeline_run_node_steps_spec.rb +0 -36
- data/spec/models/pipeline_run_nodes_spec.rb +0 -36
- data/spec/models/pipeline_run_steps_spec.rb +0 -36
- data/spec/models/pipeline_runs_spec.rb +0 -36
- data/spec/models/pipelines_spec.rb +0 -36
- data/spec/models/scm_organisations_spec.rb +0 -36
- data/spec/models/user_favorites_spec.rb +0 -36
- data/spec/models/users_spec.rb +0 -36
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
#Jenkins API clients generated from Swagger / Open API specification
|
5
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: 1.3.0
|
7
7
|
Contact: blah@cliffano.com
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.4.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -14,8 +14,8 @@ require 'date'
|
|
14
14
|
require 'json'
|
15
15
|
require 'logger'
|
16
16
|
require 'tempfile'
|
17
|
+
require 'time'
|
17
18
|
require 'typhoeus'
|
18
|
-
require 'uri'
|
19
19
|
|
20
20
|
module SwaggyJenkinsClient
|
21
21
|
class ApiClient
|
@@ -31,9 +31,9 @@ module SwaggyJenkinsClient
|
|
31
31
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
32
32
|
def initialize(config = Configuration.default)
|
33
33
|
@config = config
|
34
|
-
@user_agent = "
|
34
|
+
@user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
|
35
35
|
@default_headers = {
|
36
|
-
'Content-Type' =>
|
36
|
+
'Content-Type' => 'application/json',
|
37
37
|
'User-Agent' => @user_agent
|
38
38
|
}
|
39
39
|
end
|
@@ -44,7 +44,7 @@ module SwaggyJenkinsClient
|
|
44
44
|
|
45
45
|
# Call an API with given options.
|
46
46
|
#
|
47
|
-
# @return [Array<(Object,
|
47
|
+
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
48
48
|
# the data deserialized from response body (could be nil), response status code and response headers.
|
49
49
|
def call_api(http_method, path, opts = {})
|
50
50
|
request = build_request(http_method, path, opts)
|
@@ -87,7 +87,7 @@ module SwaggyJenkinsClient
|
|
87
87
|
# @option opts [Object] :body HTTP body (JSON/XML)
|
88
88
|
# @return [Typhoeus::Request] A Typhoeus Request
|
89
89
|
def build_request(http_method, path, opts = {})
|
90
|
-
url = build_request_url(path)
|
90
|
+
url = build_request_url(path, opts)
|
91
91
|
http_method = http_method.to_sym.downcase
|
92
92
|
|
93
93
|
header_params = @default_headers.merge(opts[:header_params] || {})
|
@@ -128,6 +128,72 @@ module SwaggyJenkinsClient
|
|
128
128
|
request
|
129
129
|
end
|
130
130
|
|
131
|
+
# Builds the HTTP request body
|
132
|
+
#
|
133
|
+
# @param [Hash] header_params Header parameters
|
134
|
+
# @param [Hash] form_params Query parameters
|
135
|
+
# @param [Object] body HTTP body (JSON/XML)
|
136
|
+
# @return [String] HTTP body data in the form of string
|
137
|
+
def build_request_body(header_params, form_params, body)
|
138
|
+
# http form
|
139
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
140
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
141
|
+
data = {}
|
142
|
+
form_params.each do |key, value|
|
143
|
+
case value
|
144
|
+
when ::File, ::Array, nil
|
145
|
+
# let typhoeus handle File, Array and nil parameters
|
146
|
+
data[key] = value
|
147
|
+
else
|
148
|
+
data[key] = value.to_s
|
149
|
+
end
|
150
|
+
end
|
151
|
+
elsif body
|
152
|
+
data = body.is_a?(String) ? body : body.to_json
|
153
|
+
else
|
154
|
+
data = nil
|
155
|
+
end
|
156
|
+
data
|
157
|
+
end
|
158
|
+
|
159
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
160
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
161
|
+
# The response body is written to the file in chunks in order to handle files which
|
162
|
+
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
163
|
+
# process can use.
|
164
|
+
#
|
165
|
+
# @see Configuration#temp_folder_path
|
166
|
+
def download_file(request)
|
167
|
+
tempfile = nil
|
168
|
+
encoding = nil
|
169
|
+
request.on_headers do |response|
|
170
|
+
content_disposition = response.headers['Content-Disposition']
|
171
|
+
if content_disposition && content_disposition =~ /filename=/i
|
172
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
173
|
+
prefix = sanitize_filename(filename)
|
174
|
+
else
|
175
|
+
prefix = 'download-'
|
176
|
+
end
|
177
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
178
|
+
encoding = response.body.encoding
|
179
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
180
|
+
@tempfile = tempfile
|
181
|
+
end
|
182
|
+
request.on_body do |chunk|
|
183
|
+
chunk.force_encoding(encoding)
|
184
|
+
tempfile.write(chunk)
|
185
|
+
end
|
186
|
+
request.on_complete do |response|
|
187
|
+
if tempfile
|
188
|
+
tempfile.close
|
189
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
190
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
191
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
192
|
+
"explicitly with `tempfile.delete`"
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
131
197
|
# Check if the given MIME is a JSON MIME.
|
132
198
|
# JSON MIME examples:
|
133
199
|
# application/json
|
@@ -137,13 +203,13 @@ module SwaggyJenkinsClient
|
|
137
203
|
# @param [String] mime MIME
|
138
204
|
# @return [Boolean] True if the MIME is application/json
|
139
205
|
def json_mime?(mime)
|
140
|
-
|
206
|
+
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
141
207
|
end
|
142
208
|
|
143
209
|
# Deserialize the response to the given return type.
|
144
210
|
#
|
145
211
|
# @param [Response] response HTTP response
|
146
|
-
# @param [String] return_type some examples: "User", "Array
|
212
|
+
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
147
213
|
def deserialize(response, return_type)
|
148
214
|
body = response.body
|
149
215
|
|
@@ -164,7 +230,7 @@ module SwaggyJenkinsClient
|
|
164
230
|
begin
|
165
231
|
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
166
232
|
rescue JSON::ParserError => e
|
167
|
-
if %w(String Date
|
233
|
+
if %w(String Date Time).include?(return_type)
|
168
234
|
data = body
|
169
235
|
else
|
170
236
|
raise e
|
@@ -187,11 +253,11 @@ module SwaggyJenkinsClient
|
|
187
253
|
data.to_i
|
188
254
|
when 'Float'
|
189
255
|
data.to_f
|
190
|
-
when '
|
256
|
+
when 'Boolean'
|
191
257
|
data == true
|
192
|
-
when '
|
258
|
+
when 'Time'
|
193
259
|
# parse date time (expecting ISO 8601 format)
|
194
|
-
|
260
|
+
Time.parse data
|
195
261
|
when 'Date'
|
196
262
|
# parse date time (expecting ISO 8601 format)
|
197
263
|
Date.parse data
|
@@ -201,54 +267,17 @@ module SwaggyJenkinsClient
|
|
201
267
|
when /\AArray<(.+)>\z/
|
202
268
|
# e.g. Array<Pet>
|
203
269
|
sub_type = $1
|
204
|
-
data.map {|item| convert_to_type(item, sub_type) }
|
270
|
+
data.map { |item| convert_to_type(item, sub_type) }
|
205
271
|
when /\AHash\<String, (.+)\>\z/
|
206
272
|
# e.g. Hash<String, Integer>
|
207
273
|
sub_type = $1
|
208
274
|
{}.tap do |hash|
|
209
|
-
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
|
275
|
+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
210
276
|
end
|
211
277
|
else
|
212
|
-
# models
|
213
|
-
SwaggyJenkinsClient.const_get(return_type)
|
214
|
-
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
# Save response body into a file in (the defined) temporary folder, using the filename
|
220
|
-
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
221
|
-
# The response body is written to the file in chunks in order to handle files which
|
222
|
-
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
223
|
-
# process can use.
|
224
|
-
#
|
225
|
-
# @see Configuration#temp_folder_path
|
226
|
-
def download_file(request)
|
227
|
-
tempfile = nil
|
228
|
-
encoding = nil
|
229
|
-
request.on_headers do |response|
|
230
|
-
content_disposition = response.headers['Content-Disposition']
|
231
|
-
if content_disposition and content_disposition =~ /filename=/i
|
232
|
-
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
233
|
-
prefix = sanitize_filename(filename)
|
234
|
-
else
|
235
|
-
prefix = 'download-'
|
236
|
-
end
|
237
|
-
prefix = prefix + '-' unless prefix.end_with?('-')
|
238
|
-
encoding = response.body.encoding
|
239
|
-
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
240
|
-
@tempfile = tempfile
|
241
|
-
end
|
242
|
-
request.on_body do |chunk|
|
243
|
-
chunk.force_encoding(encoding)
|
244
|
-
tempfile.write(chunk)
|
245
|
-
end
|
246
|
-
request.on_complete do |response|
|
247
|
-
tempfile.close
|
248
|
-
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
249
|
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
250
|
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
251
|
-
"explicitly with `tempfile.delete`"
|
278
|
+
# models (e.g. Pet) or oneOf
|
279
|
+
klass = SwaggyJenkinsClient.const_get(return_type)
|
280
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
252
281
|
end
|
253
282
|
end
|
254
283
|
|
@@ -261,41 +290,13 @@ module SwaggyJenkinsClient
|
|
261
290
|
filename.gsub(/.*[\/\\]/, '')
|
262
291
|
end
|
263
292
|
|
264
|
-
def build_request_url(path)
|
293
|
+
def build_request_url(path, opts = {})
|
265
294
|
# Add leading and trailing slashes to path
|
266
295
|
path = "/#{path}".gsub(/\/+/, '/')
|
267
|
-
|
268
|
-
end
|
269
|
-
|
270
|
-
# Builds the HTTP request body
|
271
|
-
#
|
272
|
-
# @param [Hash] header_params Header parameters
|
273
|
-
# @param [Hash] form_params Query parameters
|
274
|
-
# @param [Object] body HTTP body (JSON/XML)
|
275
|
-
# @return [String] HTTP body data in the form of string
|
276
|
-
def build_request_body(header_params, form_params, body)
|
277
|
-
# http form
|
278
|
-
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
279
|
-
header_params['Content-Type'] == 'multipart/form-data'
|
280
|
-
data = {}
|
281
|
-
form_params.each do |key, value|
|
282
|
-
case value
|
283
|
-
when File, Array, nil
|
284
|
-
# let typhoeus handle File, Array and nil parameters
|
285
|
-
data[key] = value
|
286
|
-
else
|
287
|
-
data[key] = value.to_s
|
288
|
-
end
|
289
|
-
end
|
290
|
-
elsif body
|
291
|
-
data = body.is_a?(String) ? body : body.to_json
|
292
|
-
else
|
293
|
-
data = nil
|
294
|
-
end
|
295
|
-
data
|
296
|
+
@config.base_url(opts[:operation]) + path
|
296
297
|
end
|
297
298
|
|
298
|
-
# Update
|
299
|
+
# Update header and query params based on authentication settings.
|
299
300
|
#
|
300
301
|
# @param [Hash] header_params Header parameters
|
301
302
|
# @param [Hash] query_params Query parameters
|
@@ -307,14 +308,14 @@ module SwaggyJenkinsClient
|
|
307
308
|
case auth_setting[:in]
|
308
309
|
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
309
310
|
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
310
|
-
else fail ArgumentError, 'Authentication token must be in `query`
|
311
|
+
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
|
311
312
|
end
|
312
313
|
end
|
313
314
|
end
|
314
315
|
|
315
316
|
# Sets user agent in HTTP header
|
316
317
|
#
|
317
|
-
# @param [String] user_agent User agent (e.g.
|
318
|
+
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
|
318
319
|
def user_agent=(user_agent)
|
319
320
|
@user_agent = user_agent
|
320
321
|
@default_headers['User-Agent'] = @user_agent
|
@@ -327,18 +328,18 @@ module SwaggyJenkinsClient
|
|
327
328
|
return nil if accepts.nil? || accepts.empty?
|
328
329
|
# use JSON when present, otherwise use all of the provided
|
329
330
|
json_accept = accepts.find { |s| json_mime?(s) }
|
330
|
-
|
331
|
+
json_accept || accepts.join(',')
|
331
332
|
end
|
332
333
|
|
333
334
|
# Return Content-Type header based on an array of content types provided.
|
334
335
|
# @param [Array] content_types array for Content-Type
|
335
336
|
# @return [String] the Content-Type header (e.g. application/json)
|
336
337
|
def select_header_content_type(content_types)
|
337
|
-
#
|
338
|
-
return
|
338
|
+
# return nil by default
|
339
|
+
return if content_types.nil? || content_types.empty?
|
339
340
|
# use JSON when present, otherwise use the first one
|
340
341
|
json_content_type = content_types.find { |s| json_mime?(s) }
|
341
|
-
|
342
|
+
json_content_type || content_types.first
|
342
343
|
end
|
343
344
|
|
344
345
|
# Convert object (array, hash, object, etc) to JSON string.
|
@@ -348,7 +349,7 @@ module SwaggyJenkinsClient
|
|
348
349
|
return model if model.nil? || model.is_a?(String)
|
349
350
|
local_body = nil
|
350
351
|
if model.is_a?(Array)
|
351
|
-
local_body = model.map{|m| object_to_hash(m) }
|
352
|
+
local_body = model.map { |m| object_to_hash(m) }
|
352
353
|
else
|
353
354
|
local_body = object_to_hash(model)
|
354
355
|
end
|
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
#Jenkins API clients generated from Swagger / Open API specification
|
5
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: 1.3.0
|
7
7
|
Contact: blah@cliffano.com
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.4.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -34,5 +34,24 @@ module SwaggyJenkinsClient
|
|
34
34
|
super arg
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
# Override to_s to display a friendly error message
|
39
|
+
def to_s
|
40
|
+
message
|
41
|
+
end
|
42
|
+
|
43
|
+
def message
|
44
|
+
if @message.nil?
|
45
|
+
msg = "Error message: the server returns an error"
|
46
|
+
else
|
47
|
+
msg = @message
|
48
|
+
end
|
49
|
+
|
50
|
+
msg += "\nHTTP status code: #{code}" if code
|
51
|
+
msg += "\nResponse headers: #{response_headers}" if response_headers
|
52
|
+
msg += "\nResponse body: #{response_body}" if response_body
|
53
|
+
|
54
|
+
msg
|
55
|
+
end
|
37
56
|
end
|
38
57
|
end
|
@@ -3,15 +3,13 @@
|
|
3
3
|
|
4
4
|
#Jenkins API clients generated from Swagger / Open API specification
|
5
5
|
|
6
|
-
OpenAPI
|
6
|
+
The version of the OpenAPI document: 1.3.0
|
7
7
|
Contact: blah@cliffano.com
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.4.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
|
-
require 'uri'
|
14
|
-
|
15
13
|
module SwaggyJenkinsClient
|
16
14
|
class Configuration
|
17
15
|
# Defines url scheme
|
@@ -23,6 +21,18 @@ module SwaggyJenkinsClient
|
|
23
21
|
# Defines url base path
|
24
22
|
attr_accessor :base_path
|
25
23
|
|
24
|
+
# Define server configuration index
|
25
|
+
attr_accessor :server_index
|
26
|
+
|
27
|
+
# Define server operation configuration index
|
28
|
+
attr_accessor :server_operation_index
|
29
|
+
|
30
|
+
# Default server variables
|
31
|
+
attr_accessor :server_variables
|
32
|
+
|
33
|
+
# Default server operation variables
|
34
|
+
attr_accessor :server_operation_variables
|
35
|
+
|
26
36
|
# Defines API keys used with API Key authentications.
|
27
37
|
#
|
28
38
|
# @return [Hash] key: parameter name, value: parameter value (API key)
|
@@ -129,17 +139,21 @@ module SwaggyJenkinsClient
|
|
129
139
|
|
130
140
|
def initialize
|
131
141
|
@scheme = 'http'
|
132
|
-
@host = ''
|
133
|
-
@base_path = '
|
142
|
+
@host = 'localhost'
|
143
|
+
@base_path = ''
|
144
|
+
@server_index = 0
|
145
|
+
@server_operation_index = {}
|
146
|
+
@server_variables = {}
|
147
|
+
@server_operation_variables = {}
|
134
148
|
@api_key = {}
|
135
149
|
@api_key_prefix = {}
|
136
|
-
@timeout = 0
|
137
150
|
@client_side_validation = true
|
138
151
|
@verify_ssl = true
|
139
152
|
@verify_ssl_host = true
|
140
153
|
@params_encoding = nil
|
141
154
|
@cert_file = nil
|
142
155
|
@key_file = nil
|
156
|
+
@timeout = 0
|
143
157
|
@debugging = false
|
144
158
|
@inject_format = false
|
145
159
|
@force_ending_format = false
|
@@ -170,21 +184,26 @@ module SwaggyJenkinsClient
|
|
170
184
|
def base_path=(base_path)
|
171
185
|
# Add leading and trailing slashes to base_path
|
172
186
|
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
173
|
-
@base_path =
|
187
|
+
@base_path = '' if @base_path == '/'
|
174
188
|
end
|
175
189
|
|
176
|
-
|
177
|
-
|
178
|
-
|
190
|
+
# Returns base URL for specified operation based on server settings
|
191
|
+
def base_url(operation = nil)
|
192
|
+
index = server_operation_index.fetch(operation, server_index)
|
193
|
+
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
|
194
|
+
|
195
|
+
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
179
196
|
end
|
180
197
|
|
181
198
|
# Gets API key (with prefix if set).
|
182
199
|
# @param [String] param_name the parameter name of API key auth
|
183
|
-
def api_key_with_prefix(param_name)
|
200
|
+
def api_key_with_prefix(param_name, param_alias = nil)
|
201
|
+
key = @api_key[param_name]
|
202
|
+
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
|
184
203
|
if @api_key_prefix[param_name]
|
185
|
-
"#{@api_key_prefix[param_name]} #{
|
204
|
+
"#{@api_key_prefix[param_name]} #{key}"
|
186
205
|
else
|
187
|
-
|
206
|
+
key
|
188
207
|
end
|
189
208
|
end
|
190
209
|
|
@@ -203,7 +222,64 @@ module SwaggyJenkinsClient
|
|
203
222
|
key: 'Authorization',
|
204
223
|
value: basic_auth_token
|
205
224
|
},
|
225
|
+
'jwt_auth' =>
|
226
|
+
{
|
227
|
+
type: 'api_key',
|
228
|
+
in: 'header',
|
229
|
+
key: 'Authorization',
|
230
|
+
value: api_key_with_prefix('jwt_auth')
|
231
|
+
},
|
232
|
+
}
|
233
|
+
end
|
234
|
+
|
235
|
+
# Returns an array of Server setting
|
236
|
+
def server_settings
|
237
|
+
[
|
238
|
+
{
|
239
|
+
url: "",
|
240
|
+
description: "No description provided",
|
241
|
+
}
|
242
|
+
]
|
243
|
+
end
|
244
|
+
|
245
|
+
def operation_server_settings
|
246
|
+
{
|
206
247
|
}
|
207
248
|
end
|
249
|
+
|
250
|
+
# Returns URL based on server settings
|
251
|
+
#
|
252
|
+
# @param index array index of the server settings
|
253
|
+
# @param variables hash of variable and the corresponding value
|
254
|
+
def server_url(index, variables = {}, servers = nil)
|
255
|
+
servers = server_settings if servers == nil
|
256
|
+
|
257
|
+
# check array index out of bound
|
258
|
+
if (index < 0 || index >= servers.size)
|
259
|
+
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
260
|
+
end
|
261
|
+
|
262
|
+
server = servers[index]
|
263
|
+
url = server[:url]
|
264
|
+
|
265
|
+
return url unless server.key? :variables
|
266
|
+
|
267
|
+
# go through variable and assign a value
|
268
|
+
server[:variables].each do |name, variable|
|
269
|
+
if variables.key?(name)
|
270
|
+
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
|
271
|
+
url.gsub! "{" + name.to_s + "}", variables[name]
|
272
|
+
else
|
273
|
+
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
|
274
|
+
end
|
275
|
+
else
|
276
|
+
# use default value
|
277
|
+
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
url
|
282
|
+
end
|
283
|
+
|
208
284
|
end
|
209
285
|
end
|