Class: Buildkit::Client
- Inherits:
-
Object
- Object
- Buildkit::Client
- Includes:
- Agents, Artifacts, Builds, Jobs, Organizations, Pipelines, HeaderLinkParser
- 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/'
- CONVENIENCE_HEADERS =
Set.new(%i[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
-
#auto_paginate ⇒ Object
Returns the value of attribute auto_paginate.
-
#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, auto_paginate: false) ⇒ 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 HeaderLinkParser
Methods included from Artifacts
Methods included from Jobs
#job_env, #job_log, #retry_job
Methods included from Pipelines
#archive_pipeline, #create_pipeline, #pipeline, #pipelines, #unarchive_pipeline, #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, auto_paginate: false) ⇒ Client
Returns a new instance of Client.
43 44 45 46 47 48 49 50 |
# File 'lib/buildkit/client.rb', line 43 def initialize(endpoint: ENV.fetch('BUILDKITE_API_ENDPOINT', DEFAULT_ENDPOINT), token: ENV.fetch('BUILDKITE_API_TOKEN'), middleware: self.class.build_middleware, auto_paginate: false) @middleware = middleware @endpoint = endpoint @token = token @auto_paginate = auto_paginate end |
Instance Attribute Details
#auto_paginate ⇒ Object
Returns the value of attribute auto_paginate.
31 32 33 |
# File 'lib/buildkit/client.rb', line 31 def auto_paginate @auto_paginate end |
#last_response ⇒ Object (readonly)
Returns the value of attribute last_response.
110 111 112 |
# File 'lib/buildkit/client.rb', line 110 def last_response @last_response end |
Class Method Details
.build_middleware ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/buildkit/client.rb', line 34 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
97 98 99 |
# File 'lib/buildkit/client.rb', line 97 def delete(url, = {}) request :delete, url, end |
#get(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP GET request
57 58 59 60 61 62 63 |
# File 'lib/buildkit/client.rb', line 57 def get(url, = {}) if @auto_paginate paginate :get, url, parse_query_and_convenience_headers() else request :get, url, parse_query_and_convenience_headers() end end |
#head(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP HEAD request
106 107 108 |
# File 'lib/buildkit/client.rb', line 106 def head(url, = {}) request :head, url, parse_query_and_convenience_headers() end |
#patch(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PATCH request
88 89 90 |
# File 'lib/buildkit/client.rb', line 88 def patch(url, = {}) request :patch, url, end |
#post(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP POST request
70 71 72 |
# File 'lib/buildkit/client.rb', line 70 def post(url, = {}) request :post, url, end |
#put(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PUT request
79 80 81 |
# File 'lib/buildkit/client.rb', line 79 def put(url, = {}) request :put, url, end |
#root ⇒ Sawyer::Resource
Fetch the root resource for the API
115 116 117 |
# File 'lib/buildkit/client.rb', line 115 def root get('/') end |