Class: DroneCI::Client
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Instance Method Summary collapse
-
#initialize(**options) ⇒ Client
constructor
A new instance of Client.
Methods included from UsersAPI
#users_create, #users_delete, #users_info, #users_list, #users_update
Methods included from UserAPI
#user_builds, #user_info, #user_repos, #user_sync, #user_token
Methods included from TemplatesAPI
#template_create, #template_delete, #template_info, #template_list, #template_update
Methods included from SecretsAPI
#secret_create, #secret_delete, #secret_info, #secret_list, #secret_update
Methods included from ReposAPI
#repo_chown, #repo_create, #repo_delete, #repo_info, #repo_list, #repo_repair, #repo_update
Methods included from CronAPI
#cron_create, #cron_delete, #cron_info, #cron_list, #cron_trigger, #cron_update
Methods included from BuildsAPI
#build_approve, #build_create, #build_decline, #build_info, #build_list, #build_logs, #build_promote, #build_start, #build_stop
Constructor Details
#initialize(**options) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/drone-ci/client.rb', line 13 def initialize(**) @api = .fetch(:client) do server = .fetch(:server) { ENV.fetch('DRONE_SERVER') } token = .fetch(:token) { ENV.fetch('DRONE_TOKEN') } Faraday.new(server) do |client| client.adapter :httpx client.headers = { 'Authorization' => "Bearer #{token}" }.merge(.fetch(:headers, {})) client.path_prefix = '/api' client.request :json client.request :retry client.response :json yield client if block_given? end end end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
31 32 33 |
# File 'lib/drone-ci/client.rb', line 31 def api @api end |