Class: Buildkit::Client
- Inherits:
-
Object
- Object
- Buildkit::Client
- Defined in:
- lib/buildkit/client.rb,
lib/buildkit/client/jobs.rb,
lib/buildkit/client/agents.rb,
lib/buildkit/client/builds.rb,
lib/buildkit/client/artifacts.rb,
lib/buildkit/client/pipelines.rb,
lib/buildkit/client/organizations.rb
Defined Under Namespace
Modules: Agents, Artifacts, Builds, Jobs, Organizations, Pipelines
Constant Summary collapse
- DEFAULT_ENDPOINT =
'https://api.buildkite.com/v2/'.freeze
- CONVENIENCE_HEADERS =
Set.new([:accept, :content_type])
- RACK_BUILDER_CLASS =
In Faraday 0.9, Faraday::Builder was renamed to Faraday::RackBuilder
defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
Instance Attribute Summary collapse
-
#last_response ⇒ Object
readonly
Returns the value of attribute last_response.
Class Method Summary collapse
Instance Method Summary collapse
-
#delete(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP DELETE request.
-
#get(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP GET request.
-
#head(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP HEAD request.
-
#initialize(endpoint: ENV.fetch('BUILDKITE_API_ENDPOINT', DEFAULT_ENDPOINT), token: ENV.fetch('BUILDKITE_API_TOKEN'), middleware: self.class.build_middleware) ⇒ Client
constructor
A new instance of Client.
-
#patch(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PATCH request.
-
#post(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP POST request.
-
#put(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PUT request.
-
#root ⇒ Sawyer::Resource
Fetch the root resource for the API.
Methods included from Artifacts
Methods included from Jobs
Methods included from Pipelines
#create_pipeline, #pipeline, #pipelines, #update_pipeline
Methods included from Organizations
Methods included from Builds
#build, #builds, #cancel_build, #create_build, #organization_builds, #pipeline_builds, #rebuild
Methods included from Agents
Constructor Details
#initialize(endpoint: ENV.fetch('BUILDKITE_API_ENDPOINT', DEFAULT_ENDPOINT), token: ENV.fetch('BUILDKITE_API_TOKEN'), middleware: self.class.build_middleware) ⇒ Client
Returns a new instance of Client.
37 38 39 40 41 42 43 |
# File 'lib/buildkit/client.rb', line 37 def initialize(endpoint: ENV.fetch('BUILDKITE_API_ENDPOINT', DEFAULT_ENDPOINT), token: ENV.fetch('BUILDKITE_API_TOKEN'), middleware: self.class.build_middleware) @middleware = middleware @endpoint = endpoint @token = token end |
Instance Attribute Details
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
99 100 101 |
# File 'lib/buildkit/client.rb', line 99 def last_response @last_response end |
Class Method Details
.build_middleware ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/buildkit/client.rb', line 28 def build_middleware RACK_BUILDER_CLASS.new do |builder| builder.use Buildkit::Response::RaiseError builder.adapter Faraday.default_adapter yield builder if block_given? end end |
Instance Method Details
#delete(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP DELETE request
86 87 88 |
# File 'lib/buildkit/client.rb', line 86 def delete(url, = {}) request :delete, url, end |
#get(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP GET request
50 51 52 |
# File 'lib/buildkit/client.rb', line 50 def get(url, = {}) request :get, url, parse_query_and_convenience_headers() end |
#head(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP HEAD request
95 96 97 |
# File 'lib/buildkit/client.rb', line 95 def head(url, = {}) request :head, url, parse_query_and_convenience_headers() end |
#patch(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PATCH request
77 78 79 |
# File 'lib/buildkit/client.rb', line 77 def patch(url, = {}) request :patch, url, end |
#post(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP POST request
59 60 61 |
# File 'lib/buildkit/client.rb', line 59 def post(url, = {}) request :post, url, end |
#put(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PUT request
68 69 70 |
# File 'lib/buildkit/client.rb', line 68 def put(url, = {}) request :put, url, end |
#root ⇒ Sawyer::Resource
Fetch the root resource for the API
104 105 106 |
# File 'lib/buildkit/client.rb', line 104 def root get('/') end |