Class: Buildkit::Client

Inherits:
Object
  • Object
show all
Includes:
Agents, Builds, Organizations, Projects
Defined in:
lib/buildkit/client.rb,
lib/buildkit/client/agents.rb,
lib/buildkit/client/builds.rb,
lib/buildkit/client/projects.rb,
lib/buildkit/client/organizations.rb

Defined Under Namespace

Modules: Agents, Builds, Organizations, Projects

Constant Summary collapse

CONVENIENCE_HEADERS =

Header keys that can be passed in options hash to #get,#head

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
MIDDLEWARE =

Default Faraday middleware stack

RACK_BUILDER_CLASS.new do |builder|
  builder.use Buildkit::Response::RaiseError
  builder.adapter Faraday.default_adapter
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Projects

#project, #projects

Methods included from Organizations

#organization, #organizations

Methods included from Builds

#build, #builds, #organization_builds, #project_builds, #rebuild

Methods included from Agents

#agent, #agents, #create_agent, #delete_agent, #stop_agent

Constructor Details

#initialize(token:) ⇒ Client

Returns a new instance of Client.



27
28
29
# File 'lib/buildkit/client.rb', line 27

def initialize(token:)
  @token = token
end

Instance Attribute Details

#last_responseObject (readonly)

Returns the value of attribute last_response.



85
86
87
# File 'lib/buildkit/client.rb', line 85

def last_response
  @last_response
end

Instance Method Details

#delete(url, options = {}) ⇒ Sawyer::Resource

Make a HTTP DELETE request

Parameters:

  • url (String)

    The path, relative to #api_endpoint

  • options (Hash) (defaults to: {})

    Query and header params for request

Returns:

  • (Sawyer::Resource)


72
73
74
# File 'lib/buildkit/client.rb', line 72

def delete(url, options = {})
  request :delete, url, options
end

#get(url, options = {}) ⇒ Sawyer::Resource

Make a HTTP GET request

Parameters:

  • url (String)

    The path, relative to #api_endpoint

  • options (Hash) (defaults to: {})

    Query and header params for request

Returns:

  • (Sawyer::Resource)


36
37
38
# File 'lib/buildkit/client.rb', line 36

def get(url, options = {})
  request :get, url, parse_query_and_convenience_headers(options)
end

#head(url, options = {}) ⇒ Sawyer::Resource

Make a HTTP HEAD request

Parameters:

  • url (String)

    The path, relative to #api_endpoint

  • options (Hash) (defaults to: {})

    Query and header params for request

Returns:

  • (Sawyer::Resource)


81
82
83
# File 'lib/buildkit/client.rb', line 81

def head(url, options = {})
  request :head, url, parse_query_and_convenience_headers(options)
end

#patch(url, options = {}) ⇒ Sawyer::Resource

Make a HTTP PATCH request

Parameters:

  • url (String)

    The path, relative to #api_endpoint

  • options (Hash) (defaults to: {})

    Body and header params for request

Returns:

  • (Sawyer::Resource)


63
64
65
# File 'lib/buildkit/client.rb', line 63

def patch(url, options = {})
  request :patch, url, options
end

#post(url, options = {}) ⇒ Sawyer::Resource

Make a HTTP POST request

Parameters:

  • url (String)

    The path, relative to #api_endpoint

  • options (Hash) (defaults to: {})

    Body and header params for request

Returns:

  • (Sawyer::Resource)


45
46
47
# File 'lib/buildkit/client.rb', line 45

def post(url, options = {})
  request :post, url, options
end

#put(url, options = {}) ⇒ Sawyer::Resource

Make a HTTP PUT request

Parameters:

  • url (String)

    The path, relative to #api_endpoint

  • options (Hash) (defaults to: {})

    Body and header params for request

Returns:

  • (Sawyer::Resource)


54
55
56
# File 'lib/buildkit/client.rb', line 54

def put(url, options = {})
  request :put, url, options
end

#rootSawyer::Resource

Fetch the root resource for the API

Returns:

  • (Sawyer::Resource)


90
91
92
# File 'lib/buildkit/client.rb', line 90

def root
  get('/')
end