swaggy_jenkins 0.0.1 → 2.0.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 +27 -0
- data/bin/coderay +27 -0
- data/bin/htmldiff +27 -0
- data/bin/ldiff +27 -0
- data/bin/pry +27 -0
- data/bin/rake +27 -0
- data/bin/rspec +27 -0
- data/bin/rubocop +27 -0
- data/bin/ruby-parse +27 -0
- data/bin/ruby-rewrite +27 -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 +98 -95
- data/lib/swaggy_jenkins/api_error.rb +22 -3
- data/lib/swaggy_jenkins/configuration.rb +93 -16
- data/lib/swaggy_jenkins/models/all_view.rb +60 -29
- data/lib/swaggy_jenkins/models/branch_impl.rb +77 -46
- data/lib/swaggy_jenkins/models/branch_impllinks.rb +63 -32
- data/lib/swaggy_jenkins/models/branch_implpermissions.rb +66 -35
- data/lib/swaggy_jenkins/models/cause_action.rb +59 -28
- data/lib/swaggy_jenkins/models/cause_user_id_cause.rb +64 -33
- data/lib/swaggy_jenkins/models/classes_by_class.rb +59 -28
- data/lib/swaggy_jenkins/models/clock_difference.rb +59 -28
- data/lib/swaggy_jenkins/models/computer_set.rb +65 -34
- data/lib/swaggy_jenkins/models/default_crumb_issuer.rb +61 -30
- data/lib/swaggy_jenkins/models/disk_space_monitor_descriptor_disk_space.rb +61 -30
- data/lib/swaggy_jenkins/models/empty_change_log_set.rb +59 -28
- data/lib/swaggy_jenkins/models/extension_class_container_impl1.rb +60 -29
- data/lib/swaggy_jenkins/models/extension_class_container_impl1links.rb +60 -29
- data/lib/swaggy_jenkins/models/extension_class_container_impl1map.rb +62 -31
- data/lib/swaggy_jenkins/models/extension_class_impl.rb +60 -29
- data/lib/swaggy_jenkins/models/extension_class_impllinks.rb +60 -29
- data/lib/swaggy_jenkins/models/favorite_impl.rb +60 -29
- data/lib/swaggy_jenkins/models/favorite_impllinks.rb +60 -29
- data/lib/swaggy_jenkins/models/free_style_build.rb +84 -53
- data/lib/swaggy_jenkins/models/free_style_project.rb +106 -75
- data/lib/swaggy_jenkins/models/free_style_projectactions.rb +58 -27
- data/lib/swaggy_jenkins/models/free_style_projecthealth_report.rb +64 -33
- data/lib/swaggy_jenkins/models/generic_resource.rb +66 -35
- data/lib/swaggy_jenkins/models/github_content.rb +66 -35
- data/lib/swaggy_jenkins/models/github_file.rb +59 -28
- data/lib/swaggy_jenkins/models/github_organization.rb +63 -32
- data/lib/swaggy_jenkins/models/github_organizationlinks.rb +61 -30
- data/lib/swaggy_jenkins/models/github_repositories.rb +66 -35
- data/lib/swaggy_jenkins/models/github_repositorieslinks.rb +60 -29
- data/lib/swaggy_jenkins/models/github_repository.rb +68 -37
- data/lib/swaggy_jenkins/models/github_repositorylinks.rb +60 -29
- data/lib/swaggy_jenkins/models/github_repositorypermissions.rb +64 -33
- data/lib/swaggy_jenkins/models/github_respository_container.rb +60 -29
- data/lib/swaggy_jenkins/models/github_respository_containerlinks.rb +60 -29
- data/lib/swaggy_jenkins/models/github_scm.rb +63 -32
- data/lib/swaggy_jenkins/models/github_scmlinks.rb +60 -29
- data/lib/swaggy_jenkins/models/hudson.rb +85 -54
- data/lib/swaggy_jenkins/models/hudson_master_computer.rb +90 -59
- data/lib/swaggy_jenkins/models/hudson_master_computerexecutors.rb +67 -36
- data/lib/swaggy_jenkins/models/hudson_master_computermonitor_data.rb +70 -39
- data/lib/swaggy_jenkins/models/hudsonassigned_labels.rb +58 -27
- data/lib/swaggy_jenkins/models/input_step_impl.rb +64 -33
- data/lib/swaggy_jenkins/models/input_step_impllinks.rb +60 -29
- data/lib/swaggy_jenkins/models/label1.rb +58 -27
- data/lib/swaggy_jenkins/models/link.rb +59 -28
- data/lib/swaggy_jenkins/models/list_view.rb +62 -31
- data/lib/swaggy_jenkins/models/multibranch_pipeline.rb +82 -51
- data/lib/swaggy_jenkins/models/null_scm.rb +58 -27
- data/lib/swaggy_jenkins/models/organisation.rb +59 -28
- data/lib/swaggy_jenkins/models/pipeline.rb +70 -39
- data/lib/swaggy_jenkins/models/pipeline_activity.rb +79 -48
- data/lib/swaggy_jenkins/models/pipeline_activityartifacts.rb +61 -30
- data/lib/swaggy_jenkins/models/pipeline_branchesitem.rb +72 -41
- data/lib/swaggy_jenkins/models/pipeline_branchesitemlatest_run.rb +78 -47
- data/lib/swaggy_jenkins/models/pipeline_branchesitempull_request.rb +63 -32
- data/lib/swaggy_jenkins/models/pipeline_branchesitempull_requestlinks.rb +60 -29
- data/lib/swaggy_jenkins/models/pipeline_folder_impl.rb +68 -37
- data/lib/swaggy_jenkins/models/pipeline_impl.rb +71 -40
- data/lib/swaggy_jenkins/models/pipeline_impllinks.rb +63 -32
- data/lib/swaggy_jenkins/models/pipeline_run.rb +79 -48
- data/lib/swaggy_jenkins/models/pipeline_run_impl.rb +79 -48
- data/lib/swaggy_jenkins/models/pipeline_run_impllinks.rb +64 -33
- data/lib/swaggy_jenkins/models/pipeline_run_node.rb +68 -37
- data/lib/swaggy_jenkins/models/pipeline_run_nodeedges.rb +59 -28
- data/lib/swaggy_jenkins/models/pipeline_runartifacts.rb +61 -30
- data/lib/swaggy_jenkins/models/pipeline_step_impl.rb +69 -38
- data/lib/swaggy_jenkins/models/pipeline_step_impllinks.rb +61 -30
- data/lib/swaggy_jenkins/models/pipelinelatest_run.rb +79 -48
- data/lib/swaggy_jenkins/models/pipelinelatest_runartifacts.rb +61 -30
- data/lib/swaggy_jenkins/models/queue.rb +59 -28
- data/lib/swaggy_jenkins/models/queue_blocked_item.rb +74 -43
- data/lib/swaggy_jenkins/models/queue_item_impl.rb +64 -33
- data/lib/swaggy_jenkins/models/queue_left_item.rb +75 -44
- data/lib/swaggy_jenkins/models/response_time_monitor_data.rb +60 -29
- data/lib/swaggy_jenkins/models/string_parameter_definition.rb +63 -32
- data/lib/swaggy_jenkins/models/string_parameter_value.rb +60 -29
- data/lib/swaggy_jenkins/models/swap_space_monitor_memory_usage2.rb +66 -35
- data/lib/swaggy_jenkins/models/unlabeled_load_statistics.rb +58 -27
- data/lib/swaggy_jenkins/models/user.rb +63 -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 +96 -274
- 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: 2.0.0
|
7
7
|
Contact: blah@cliffano.com
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.0.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,12 +87,13 @@ 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] || {})
|
94
94
|
query_params = opts[:query_params] || {}
|
95
95
|
form_params = opts[:form_params] || {}
|
96
|
+
follow_location = opts[:follow_location] || true
|
96
97
|
|
97
98
|
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
98
99
|
|
@@ -109,7 +110,8 @@ module SwaggyJenkinsClient
|
|
109
110
|
:ssl_verifyhost => _verify_ssl_host,
|
110
111
|
:sslcert => @config.cert_file,
|
111
112
|
:sslkey => @config.key_file,
|
112
|
-
:verbose => @config.debugging
|
113
|
+
:verbose => @config.debugging,
|
114
|
+
:followlocation => follow_location
|
113
115
|
}
|
114
116
|
|
115
117
|
# set custom cert, if provided
|
@@ -128,6 +130,72 @@ module SwaggyJenkinsClient
|
|
128
130
|
request
|
129
131
|
end
|
130
132
|
|
133
|
+
# Builds the HTTP request body
|
134
|
+
#
|
135
|
+
# @param [Hash] header_params Header parameters
|
136
|
+
# @param [Hash] form_params Query parameters
|
137
|
+
# @param [Object] body HTTP body (JSON/XML)
|
138
|
+
# @return [String] HTTP body data in the form of string
|
139
|
+
def build_request_body(header_params, form_params, body)
|
140
|
+
# http form
|
141
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
142
|
+
header_params['Content-Type'] == 'multipart/form-data'
|
143
|
+
data = {}
|
144
|
+
form_params.each do |key, value|
|
145
|
+
case value
|
146
|
+
when ::File, ::Array, nil
|
147
|
+
# let typhoeus handle File, Array and nil parameters
|
148
|
+
data[key] = value
|
149
|
+
else
|
150
|
+
data[key] = value.to_s
|
151
|
+
end
|
152
|
+
end
|
153
|
+
elsif body
|
154
|
+
data = body.is_a?(String) ? body : body.to_json
|
155
|
+
else
|
156
|
+
data = nil
|
157
|
+
end
|
158
|
+
data
|
159
|
+
end
|
160
|
+
|
161
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
162
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
163
|
+
# The response body is written to the file in chunks in order to handle files which
|
164
|
+
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
165
|
+
# process can use.
|
166
|
+
#
|
167
|
+
# @see Configuration#temp_folder_path
|
168
|
+
def download_file(request)
|
169
|
+
tempfile = nil
|
170
|
+
encoding = nil
|
171
|
+
request.on_headers do |response|
|
172
|
+
content_disposition = response.headers['Content-Disposition']
|
173
|
+
if content_disposition && content_disposition =~ /filename=/i
|
174
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
175
|
+
prefix = sanitize_filename(filename)
|
176
|
+
else
|
177
|
+
prefix = 'download-'
|
178
|
+
end
|
179
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
180
|
+
encoding = response.body.encoding
|
181
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
182
|
+
@tempfile = tempfile
|
183
|
+
end
|
184
|
+
request.on_body do |chunk|
|
185
|
+
chunk.force_encoding(encoding)
|
186
|
+
tempfile.write(chunk)
|
187
|
+
end
|
188
|
+
request.on_complete do |response|
|
189
|
+
if tempfile
|
190
|
+
tempfile.close
|
191
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
192
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
193
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
194
|
+
"explicitly with `tempfile.delete`"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
131
199
|
# Check if the given MIME is a JSON MIME.
|
132
200
|
# JSON MIME examples:
|
133
201
|
# application/json
|
@@ -137,13 +205,13 @@ module SwaggyJenkinsClient
|
|
137
205
|
# @param [String] mime MIME
|
138
206
|
# @return [Boolean] True if the MIME is application/json
|
139
207
|
def json_mime?(mime)
|
140
|
-
|
208
|
+
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
141
209
|
end
|
142
210
|
|
143
211
|
# Deserialize the response to the given return type.
|
144
212
|
#
|
145
213
|
# @param [Response] response HTTP response
|
146
|
-
# @param [String] return_type some examples: "User", "Array
|
214
|
+
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
147
215
|
def deserialize(response, return_type)
|
148
216
|
body = response.body
|
149
217
|
|
@@ -164,7 +232,7 @@ module SwaggyJenkinsClient
|
|
164
232
|
begin
|
165
233
|
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
166
234
|
rescue JSON::ParserError => e
|
167
|
-
if %w(String Date
|
235
|
+
if %w(String Date Time).include?(return_type)
|
168
236
|
data = body
|
169
237
|
else
|
170
238
|
raise e
|
@@ -187,11 +255,11 @@ module SwaggyJenkinsClient
|
|
187
255
|
data.to_i
|
188
256
|
when 'Float'
|
189
257
|
data.to_f
|
190
|
-
when '
|
258
|
+
when 'Boolean'
|
191
259
|
data == true
|
192
|
-
when '
|
260
|
+
when 'Time'
|
193
261
|
# parse date time (expecting ISO 8601 format)
|
194
|
-
|
262
|
+
Time.parse data
|
195
263
|
when 'Date'
|
196
264
|
# parse date time (expecting ISO 8601 format)
|
197
265
|
Date.parse data
|
@@ -201,54 +269,17 @@ module SwaggyJenkinsClient
|
|
201
269
|
when /\AArray<(.+)>\z/
|
202
270
|
# e.g. Array<Pet>
|
203
271
|
sub_type = $1
|
204
|
-
data.map {|item| convert_to_type(item, sub_type) }
|
272
|
+
data.map { |item| convert_to_type(item, sub_type) }
|
205
273
|
when /\AHash\<String, (.+)\>\z/
|
206
274
|
# e.g. Hash<String, Integer>
|
207
275
|
sub_type = $1
|
208
276
|
{}.tap do |hash|
|
209
|
-
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
|
277
|
+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
210
278
|
end
|
211
279
|
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`"
|
280
|
+
# models (e.g. Pet) or oneOf
|
281
|
+
klass = SwaggyJenkinsClient.const_get(return_type)
|
282
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
252
283
|
end
|
253
284
|
end
|
254
285
|
|
@@ -261,41 +292,13 @@ module SwaggyJenkinsClient
|
|
261
292
|
filename.gsub(/.*[\/\\]/, '')
|
262
293
|
end
|
263
294
|
|
264
|
-
def build_request_url(path)
|
295
|
+
def build_request_url(path, opts = {})
|
265
296
|
# Add leading and trailing slashes to path
|
266
297
|
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
|
298
|
+
@config.base_url(opts[:operation]) + path
|
296
299
|
end
|
297
300
|
|
298
|
-
# Update
|
301
|
+
# Update header and query params based on authentication settings.
|
299
302
|
#
|
300
303
|
# @param [Hash] header_params Header parameters
|
301
304
|
# @param [Hash] query_params Query parameters
|
@@ -307,14 +310,14 @@ module SwaggyJenkinsClient
|
|
307
310
|
case auth_setting[:in]
|
308
311
|
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
309
312
|
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
310
|
-
else fail ArgumentError, 'Authentication token must be in `query`
|
313
|
+
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
|
311
314
|
end
|
312
315
|
end
|
313
316
|
end
|
314
317
|
|
315
318
|
# Sets user agent in HTTP header
|
316
319
|
#
|
317
|
-
# @param [String] user_agent User agent (e.g.
|
320
|
+
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
|
318
321
|
def user_agent=(user_agent)
|
319
322
|
@user_agent = user_agent
|
320
323
|
@default_headers['User-Agent'] = @user_agent
|
@@ -327,18 +330,18 @@ module SwaggyJenkinsClient
|
|
327
330
|
return nil if accepts.nil? || accepts.empty?
|
328
331
|
# use JSON when present, otherwise use all of the provided
|
329
332
|
json_accept = accepts.find { |s| json_mime?(s) }
|
330
|
-
|
333
|
+
json_accept || accepts.join(',')
|
331
334
|
end
|
332
335
|
|
333
336
|
# Return Content-Type header based on an array of content types provided.
|
334
337
|
# @param [Array] content_types array for Content-Type
|
335
338
|
# @return [String] the Content-Type header (e.g. application/json)
|
336
339
|
def select_header_content_type(content_types)
|
337
|
-
#
|
338
|
-
return
|
340
|
+
# return nil by default
|
341
|
+
return if content_types.nil? || content_types.empty?
|
339
342
|
# use JSON when present, otherwise use the first one
|
340
343
|
json_content_type = content_types.find { |s| json_mime?(s) }
|
341
|
-
|
344
|
+
json_content_type || content_types.first
|
342
345
|
end
|
343
346
|
|
344
347
|
# Convert object (array, hash, object, etc) to JSON string.
|
@@ -348,7 +351,7 @@ module SwaggyJenkinsClient
|
|
348
351
|
return model if model.nil? || model.is_a?(String)
|
349
352
|
local_body = nil
|
350
353
|
if model.is_a?(Array)
|
351
|
-
local_body = model.map{|m| object_to_hash(m) }
|
354
|
+
local_body = model.map { |m| object_to_hash(m) }
|
352
355
|
else
|
353
356
|
local_body = object_to_hash(model)
|
354
357
|
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: 2.0.0
|
7
7
|
Contact: blah@cliffano.com
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.0.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: 2.0.0
|
7
7
|
Contact: blah@cliffano.com
|
8
|
-
Generated by: https://
|
9
|
-
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.0.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)
|
@@ -123,23 +133,28 @@ module SwaggyJenkinsClient
|
|
123
133
|
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
124
134
|
attr_accessor :params_encoding
|
125
135
|
|
136
|
+
|
126
137
|
attr_accessor :inject_format
|
127
138
|
|
128
139
|
attr_accessor :force_ending_format
|
129
140
|
|
130
141
|
def initialize
|
131
142
|
@scheme = 'http'
|
132
|
-
@host = ''
|
133
|
-
@base_path = '
|
143
|
+
@host = 'localhost'
|
144
|
+
@base_path = ''
|
145
|
+
@server_index = 0
|
146
|
+
@server_operation_index = {}
|
147
|
+
@server_variables = {}
|
148
|
+
@server_operation_variables = {}
|
134
149
|
@api_key = {}
|
135
150
|
@api_key_prefix = {}
|
136
|
-
@timeout = 0
|
137
151
|
@client_side_validation = true
|
138
152
|
@verify_ssl = true
|
139
153
|
@verify_ssl_host = true
|
140
|
-
@params_encoding = nil
|
141
154
|
@cert_file = nil
|
142
155
|
@key_file = nil
|
156
|
+
@timeout = 0
|
157
|
+
@params_encoding = nil
|
143
158
|
@debugging = false
|
144
159
|
@inject_format = false
|
145
160
|
@force_ending_format = false
|
@@ -170,21 +185,26 @@ module SwaggyJenkinsClient
|
|
170
185
|
def base_path=(base_path)
|
171
186
|
# Add leading and trailing slashes to base_path
|
172
187
|
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
173
|
-
@base_path =
|
188
|
+
@base_path = '' if @base_path == '/'
|
174
189
|
end
|
175
190
|
|
176
|
-
|
177
|
-
|
178
|
-
|
191
|
+
# Returns base URL for specified operation based on server settings
|
192
|
+
def base_url(operation = nil)
|
193
|
+
index = server_operation_index.fetch(operation, server_index)
|
194
|
+
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
|
195
|
+
|
196
|
+
server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
179
197
|
end
|
180
198
|
|
181
199
|
# Gets API key (with prefix if set).
|
182
200
|
# @param [String] param_name the parameter name of API key auth
|
183
|
-
def api_key_with_prefix(param_name)
|
201
|
+
def api_key_with_prefix(param_name, param_alias = nil)
|
202
|
+
key = @api_key[param_name]
|
203
|
+
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
|
184
204
|
if @api_key_prefix[param_name]
|
185
|
-
"#{@api_key_prefix[param_name]} #{
|
205
|
+
"#{@api_key_prefix[param_name]} #{key}"
|
186
206
|
else
|
187
|
-
|
207
|
+
key
|
188
208
|
end
|
189
209
|
end
|
190
210
|
|
@@ -203,7 +223,64 @@ module SwaggyJenkinsClient
|
|
203
223
|
key: 'Authorization',
|
204
224
|
value: basic_auth_token
|
205
225
|
},
|
226
|
+
'jwt_auth' =>
|
227
|
+
{
|
228
|
+
type: 'api_key',
|
229
|
+
in: 'header',
|
230
|
+
key: 'Authorization',
|
231
|
+
value: api_key_with_prefix('jwt_auth')
|
232
|
+
},
|
206
233
|
}
|
207
234
|
end
|
235
|
+
|
236
|
+
# Returns an array of Server setting
|
237
|
+
def server_settings
|
238
|
+
[
|
239
|
+
{
|
240
|
+
url: "",
|
241
|
+
description: "No description provided",
|
242
|
+
}
|
243
|
+
]
|
244
|
+
end
|
245
|
+
|
246
|
+
def operation_server_settings
|
247
|
+
{
|
248
|
+
}
|
249
|
+
end
|
250
|
+
|
251
|
+
# Returns URL based on server settings
|
252
|
+
#
|
253
|
+
# @param index array index of the server settings
|
254
|
+
# @param variables hash of variable and the corresponding value
|
255
|
+
def server_url(index, variables = {}, servers = nil)
|
256
|
+
servers = server_settings if servers == nil
|
257
|
+
|
258
|
+
# check array index out of bound
|
259
|
+
if (index < 0 || index >= servers.size)
|
260
|
+
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
261
|
+
end
|
262
|
+
|
263
|
+
server = servers[index]
|
264
|
+
url = server[:url]
|
265
|
+
|
266
|
+
return url unless server.key? :variables
|
267
|
+
|
268
|
+
# go through variable and assign a value
|
269
|
+
server[:variables].each do |name, variable|
|
270
|
+
if variables.key?(name)
|
271
|
+
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
|
272
|
+
url.gsub! "{" + name.to_s + "}", variables[name]
|
273
|
+
else
|
274
|
+
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
|
275
|
+
end
|
276
|
+
else
|
277
|
+
# use default value
|
278
|
+
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
url
|
283
|
+
end
|
284
|
+
|
208
285
|
end
|
209
286
|
end
|