Module: Buildkit::Client::Agents

Included in:
Buildkit::Client
Defined in:
lib/buildkit/client/agents.rb

Overview

Methods for the Agents API

Instance Method Summary collapse

Instance Method Details

#agent(org, id, options = {}) ⇒ Sawyer::Resource

Get an agent

Examples:

Buildkit.agent('my-great-org', '0b461f65-e7be-4c80-888a-ef11d81fd971')

Parameters:

  • org (String)

    Organization slug.

  • id (String)

    Agent id.

Returns:

  • (Sawyer::Resource)

    Hash representing Buildkite agent

See Also:



25
26
27
# File 'lib/buildkit/client/agents.rb', line 25

def agent(org, id, options = {})
  get("/v1/organizations/#{org}/agents/#{id}", options)
end

#agents(org, options = {}) ⇒ Array<Sawyer::Resource>

List agents

Examples:

Buildkit.agents('my-great-org')

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing Buildkite agents.

See Also:



13
14
15
# File 'lib/buildkit/client/agents.rb', line 13

def agents(org, options = {})
  get("/v1/organizations/#{org}/agents", options)
end

#create_agent(org, name, options = {}) ⇒ Sawyer::Resource

Create an agent

Examples:

Create a new Agent for an organization

Buildkit.create_agent('my-great-org', 'new-agent')

Parameters:

  • org (String)

    Organization slug.

  • name (String)

    The name of the agent.

Returns:

  • (Sawyer::Resource)

    Your newly created agent

See Also:



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

def create_agent(org, name, options = {})
  post("/v1/organizations/#{org}/agents", options.merge(name: name))
end

#delete_agent(org, id, options = {}) ⇒ Object

Delete an agent

Examples:

Delete an existing agent

Buildkit.delete_agent('my-great-org', '16940c91-f12d-4122-8154-0edf6c0978c2')

Parameters:

  • org (String)

    Organization slug.

  • id (String)

    Agent id.

See Also:



48
49
50
# File 'lib/buildkit/client/agents.rb', line 48

def delete_agent(org, id, options = {})
  delete("/v1/organizations/#{org}/agents/#{id}", options)
end

#stop_agent(org, id, options = {}) ⇒ Object

Stop an agent

Examples:

Stop an agent

Buildkit.stop_agent('my-great-org', '16940c91-f12d-4122-8154-0edf6c0978c2')

Parameters:

  • org (String)

    Organization slug.

  • id (String)

    Agent id.

See Also:



59
60
61
# File 'lib/buildkit/client/agents.rb', line 59

def stop_agent(org, id, options = {})
  put("/v1/organizations/#{org}/agents/#{id}/stop", options)
end