buildkiterb 0.2.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.env.example +2 -1
  3. data/.github/FUNDING.yml +1 -3
  4. data/.github/workflows/ci.yml +2 -2
  5. data/Gemfile +3 -1
  6. data/Gemfile.lock +5 -3
  7. data/README.md +110 -39
  8. data/bin/console +4 -1
  9. data/lib/buildkite/client.rb +54 -53
  10. data/lib/buildkite/configuration.rb +11 -0
  11. data/lib/buildkite/models/access_token.rb +18 -0
  12. data/lib/buildkite/models/agent.rb +23 -0
  13. data/lib/buildkite/models/annotation.rb +14 -0
  14. data/lib/buildkite/models/artifact.rb +33 -0
  15. data/lib/buildkite/models/build.rb +44 -0
  16. data/lib/buildkite/models/cluster.rb +34 -0
  17. data/lib/buildkite/models/cluster_queue.rb +44 -0
  18. data/lib/buildkite/models/cluster_token.rb +34 -0
  19. data/lib/buildkite/models/emoji.rb +14 -0
  20. data/lib/buildkite/models/job.rb +33 -0
  21. data/lib/buildkite/models/organization.rb +19 -0
  22. data/lib/buildkite/models/pipeline.rb +48 -0
  23. data/lib/buildkite/models/user.rb +14 -0
  24. data/lib/buildkite/version.rb +1 -1
  25. data/lib/buildkite.rb +32 -28
  26. metadata +20 -27
  27. data/lib/buildkite/objects/access_token.rb +0 -4
  28. data/lib/buildkite/objects/agent.rb +0 -4
  29. data/lib/buildkite/objects/annotation.rb +0 -4
  30. data/lib/buildkite/objects/artifact.rb +0 -4
  31. data/lib/buildkite/objects/build.rb +0 -4
  32. data/lib/buildkite/objects/emoji.rb +0 -4
  33. data/lib/buildkite/objects/job.rb +0 -4
  34. data/lib/buildkite/objects/organization.rb +0 -4
  35. data/lib/buildkite/objects/pipeline.rb +0 -4
  36. data/lib/buildkite/objects/user.rb +0 -4
  37. data/lib/buildkite/resource.rb +0 -59
  38. data/lib/buildkite/resources/access_token.rb +0 -13
  39. data/lib/buildkite/resources/agents.rb +0 -18
  40. data/lib/buildkite/resources/annotations.rb +0 -10
  41. data/lib/buildkite/resources/artifacts.rb +0 -27
  42. data/lib/buildkite/resources/builds.rb +0 -36
  43. data/lib/buildkite/resources/emojis.rb +0 -10
  44. data/lib/buildkite/resources/jobs.rb +0 -25
  45. data/lib/buildkite/resources/organizations.rb +0 -14
  46. data/lib/buildkite/resources/pipelines.rb +0 -39
  47. data/lib/buildkite/resources/user.rb +0 -9
  48. /data/lib/buildkite/{objects → models}/artifact_download.rb +0 -0
  49. /data/lib/buildkite/{objects → models}/job_env.rb +0 -0
  50. /data/lib/buildkite/{objects → models}/job_log.rb +0 -0
@@ -0,0 +1,34 @@
1
+ module Buildkite
2
+ class Cluster < Object
3
+
4
+ class << self
5
+
6
+ def list(org: Buildkite.config.org)
7
+ response = Client.get_request("organizations/#{org}/clusters")
8
+ Collection.from_response(response, type: Cluster)
9
+ end
10
+
11
+ def retrieve(org: Buildkite.config.org, id:)
12
+ response = Client.get_request("organizations/#{org}/clusters/#{id}")
13
+ Cluster.new response.body
14
+ end
15
+
16
+ def create(org: Buildkite.config.org, name:, **args)
17
+ data = {name: name}
18
+ response = Client.post_request("organizations/#{org}/clusters", body: data.merge(args))
19
+ Cluster.new response.body
20
+ end
21
+
22
+ def update(org: Buildkite.config.org, id:, **args)
23
+ response = Client.patch_request("organizations/#{org}/clusters/#{id}", body: args)
24
+ Cluster.new response.body
25
+ end
26
+
27
+ def delete(org: Buildkite.config.org, id:)
28
+ Client.delete_request("organizations/#{org}/clusters/#{id}")
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,44 @@
1
+ module Buildkite
2
+ class ClusterQueue < Object
3
+
4
+ class << self
5
+
6
+ def list(org: Buildkite.config.org, cluster:)
7
+ response = Client.get_request("organizations/#{org}/clusters/#{cluster}/queues")
8
+ Collection.from_response(response, type: ClusterQueue)
9
+ end
10
+
11
+ def retrieve(org: Buildkite.config.org, cluster:, id:)
12
+ response = Client.get_request("organizations/#{org}/clusters/#{cluster}/queues/#{id}")
13
+ ClusterQueue.new response.body
14
+ end
15
+
16
+ def create(org: Buildkite.config.org, cluster:, key:, **args)
17
+ data = {key: key}
18
+ response = Client.post_request("organizations/#{org}/clusters/#{cluster}/queues", body: data.merge(args))
19
+ ClusterQueue.new response.body
20
+ end
21
+
22
+ def update(org: Buildkite.config.org, cluster:, id:, **args)
23
+ response = Client.patch_request("organizations/#{org}/clusters/#{cluster}/queues/#{id}", body: args)
24
+ ClusterQueue.new response.body
25
+ end
26
+
27
+ def pause(org: Buildkite.config.org, cluster:, id:, note: nil)
28
+ response = Client.post_request("organizations/#{org}/clusters/#{cluster}/queues/#{id}/pause_dispatch", body: {note: note})
29
+ ClusterQueue.new response.body
30
+ end
31
+
32
+ def resume(org: Buildkite.config.org, cluster:, id:)
33
+ response = Client.post_request("organizations/#{org}/clusters/#{cluster}/queues/#{id}/resume_dispatch", body: {})
34
+ ClusterQueue.new response.body
35
+ end
36
+
37
+ def delete(org: Buildkite.config.org, cluster:, id:)
38
+ Client.delete_request("organizations/#{org}/clusters/#{cluster}/queues/#{id}")
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,34 @@
1
+ module Buildkite
2
+ class ClusterToken < Object
3
+
4
+ class << self
5
+
6
+ def list(org: Buildkite.config.org, cluster:)
7
+ response = Client.get_request("organizations/#{org}/clusters/#{cluster}/tokens")
8
+ Collection.from_response(response, type: ClusterToken)
9
+ end
10
+
11
+ def retrieve(org: Buildkite.config.org, cluster:, id:)
12
+ response = Client.get_request("organizations/#{org}/clusters/#{cluster}/tokens/#{id}")
13
+ ClusterToken.new response.body
14
+ end
15
+
16
+ def create(org: Buildkite.config.org, cluster:, description:, **args)
17
+ data = {description: description}
18
+ response = Client.post_request("organizations/#{org}/clusters/#{cluster}/tokens", body: data.merge(args))
19
+ ClusterToken.new response.body
20
+ end
21
+
22
+ def update(org: Buildkite.config.org, cluster:, id:, **args)
23
+ response = Client.patch_request("organizations/#{org}/clusters/#{cluster}/tokens/#{id}", body: args)
24
+ ClusterToken.new response.body
25
+ end
26
+
27
+ def delete(org: Buildkite.config.org, cluster:, id:)
28
+ Client.delete_request("organizations/#{org}/clusters/#{cluster}/tokens/#{id}")
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,14 @@
1
+ module Buildkite
2
+ class Emoji < Object
3
+
4
+ class << self
5
+
6
+ def list(org: Buildkite.config.org)
7
+ response = Client.get_request("organizations/#{org}/emojis")
8
+ Collection.from_response(response, type: Emoji)
9
+ end
10
+
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ module Buildkite
2
+ class Job < Object
3
+
4
+ class << self
5
+
6
+ def retry(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:, job:)
7
+ response = Client.put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/retry", body: {})
8
+ Job.new response.body
9
+ end
10
+
11
+ def unblock(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:, job:, **args)
12
+ response = Client.put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/unblock", body: args)
13
+ Job.new response.body
14
+ end
15
+
16
+ def log(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:, job:)
17
+ response = Client.get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/log")
18
+ JobLog.new response.body
19
+ end
20
+
21
+ def delete_log(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:, job:)
22
+ Client.delete_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/log")
23
+ end
24
+
25
+ def env(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, number:, job:)
26
+ response = Client.get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/jobs/#{job}/env")
27
+ JobEnv.new response.body["env"]
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,19 @@
1
+ module Buildkite
2
+ class Organization < Object
3
+
4
+ class << self
5
+
6
+ def list
7
+ response = Client.get_request("organizations")
8
+ Collection.from_response(response, type: Organization)
9
+ end
10
+
11
+ def retrieve(slug:)
12
+ response = Client.get_request("organizations/#{slug}")
13
+ Organization.new(response.body)
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,48 @@
1
+ module Buildkite
2
+ class Pipeline < Object
3
+
4
+ class << self
5
+
6
+ def list(org: Buildkite.config.org)
7
+ response = Client.get_request("organizations/#{org}/pipelines")
8
+ Collection.from_response(response, type: Pipeline)
9
+ end
10
+
11
+ def retrieve(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline)
12
+ response = Client.get_request("organizations/#{org}/pipelines/#{pipeline}")
13
+ Pipeline.new response.body
14
+ end
15
+
16
+ def create(org: Buildkite.config.org, name:, repository:, configuration:, **args)
17
+ data = {name: name, repository: repository, configuration: configuration}
18
+ response = Client.post_request("organizations/#{org}/pipelines", body: data.merge(args))
19
+ Pipeline.new response.body
20
+ end
21
+
22
+ def update(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline, **args)
23
+ response = Client.patch_request("organizations/#{org}/pipelines/#{pipeline}", body: args)
24
+ Pipeline.new response.body
25
+ end
26
+
27
+ def archive(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline)
28
+ response = Client.post_request("organizations/#{org}/pipelines/#{pipeline}/archive", body: {})
29
+ Pipeline.new response.body
30
+ end
31
+
32
+ def unarchive(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline)
33
+ response = Client.post_request("organizations/#{org}/pipelines/#{pipeline}/unarchive", body: {})
34
+ Pipeline.new response.body
35
+ end
36
+
37
+ def delete(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline)
38
+ Client.delete_request("organizations/#{org}/pipelines/#{pipeline}")
39
+ end
40
+
41
+ def webhook(org: Buildkite.config.org, pipeline: Buildkite.config.pipeline)
42
+ Client.post_request("organizations/#{org}/pipelines/#{pipeline}/webhook", body: {})
43
+ end
44
+
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,14 @@
1
+ module Buildkite
2
+ class User < Object
3
+
4
+ class << self
5
+
6
+ def retrieve
7
+ response = Client.get_request("user")
8
+ User.new response.body
9
+ end
10
+
11
+ end
12
+
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Buildkite
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/buildkite.rb CHANGED
@@ -1,38 +1,42 @@
1
1
  require "faraday"
2
- require "json"
3
- require "buildkite/version"
2
+
3
+ require_relative "buildkite/version"
4
4
 
5
5
  module Buildkite
6
6
 
7
+ autoload :Configuration, "buildkite/configuration"
7
8
  autoload :Client, "buildkite/client"
8
9
  autoload :Collection, "buildkite/collection"
9
10
  autoload :Error, "buildkite/error"
10
- autoload :Resource, "buildkite/resource"
11
11
  autoload :Object, "buildkite/object"
12
-
13
- autoload :AccessTokenResource, "buildkite/resources/access_token"
14
- autoload :OrganizationsResource, "buildkite/resources/organizations"
15
- autoload :PipelinesResource, "buildkite/resources/pipelines"
16
- autoload :BuildsResource, "buildkite/resources/builds"
17
- autoload :JobsResource, "buildkite/resources/jobs"
18
- autoload :AgentsResource, "buildkite/resources/agents"
19
- autoload :AnnotationsResource, "buildkite/resources/annotations"
20
- autoload :ArtifactsResource, "buildkite/resources/artifacts"
21
- autoload :EmojisResource, "buildkite/resources/emojis"
22
- autoload :UserResource, "buildkite/resources/user"
23
-
24
- autoload :AccessToken, "buildkite/objects/access_token"
25
- autoload :Organization, "buildkite/objects/organization"
26
- autoload :Pipeline, "buildkite/objects/pipeline"
27
- autoload :Build, "buildkite/objects/build"
28
- autoload :Job, "buildkite/objects/job"
29
- autoload :JobLog, "buildkite/objects/job_log"
30
- autoload :JobEnv, "buildkite/objects/job_env"
31
- autoload :Agent, "buildkite/objects/agent"
32
- autoload :Annotation, "buildkite/objects/annotation"
33
- autoload :Artifact, "buildkite/objects/artifact"
34
- autoload :ArtifactDownload, "buildkite/objects/artifact_download"
35
- autoload :Emoji, "buildkite/objects/emoji"
36
- autoload :User, "buildkite/objects/user"
12
+
13
+ class << self
14
+ attr_writer :config
15
+ end
16
+
17
+ def self.configure
18
+ yield(config) if block_given?
19
+ end
20
+
21
+ def self.config
22
+ @config ||= Buildkite::Configuration.new
23
+ end
24
+
25
+ autoload :AccessToken, "buildkite/models/access_token"
26
+ autoload :Organization, "buildkite/models/organization"
27
+ autoload :Pipeline, "buildkite/models/pipeline"
28
+ autoload :Build, "buildkite/models/build"
29
+ autoload :Job, "buildkite/models/job"
30
+ autoload :JobLog, "buildkite/models/job_log"
31
+ autoload :JobEnv, "buildkite/models/job_env"
32
+ autoload :Agent, "buildkite/models/agent"
33
+ autoload :Cluster, "buildkite/models/cluster"
34
+ autoload :ClusterQueue, "buildkite/models/cluster_queue"
35
+ autoload :ClusterToken, "buildkite/models/cluster_token"
36
+ autoload :Annotation, "buildkite/models/annotation"
37
+ autoload :Artifact, "buildkite/models/artifact"
38
+ autoload :ArtifactDownload, "buildkite/models/artifact_download"
39
+ autoload :Emoji, "buildkite/models/emoji"
40
+ autoload :User, "buildkite/models/user"
37
41
 
38
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildkiterb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Perry
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-07 00:00:00.000000000 Z
11
+ date: 2024-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -46,32 +46,25 @@ files:
46
46
  - lib/buildkite.rb
47
47
  - lib/buildkite/client.rb
48
48
  - lib/buildkite/collection.rb
49
+ - lib/buildkite/configuration.rb
49
50
  - lib/buildkite/error.rb
51
+ - lib/buildkite/models/access_token.rb
52
+ - lib/buildkite/models/agent.rb
53
+ - lib/buildkite/models/annotation.rb
54
+ - lib/buildkite/models/artifact.rb
55
+ - lib/buildkite/models/artifact_download.rb
56
+ - lib/buildkite/models/build.rb
57
+ - lib/buildkite/models/cluster.rb
58
+ - lib/buildkite/models/cluster_queue.rb
59
+ - lib/buildkite/models/cluster_token.rb
60
+ - lib/buildkite/models/emoji.rb
61
+ - lib/buildkite/models/job.rb
62
+ - lib/buildkite/models/job_env.rb
63
+ - lib/buildkite/models/job_log.rb
64
+ - lib/buildkite/models/organization.rb
65
+ - lib/buildkite/models/pipeline.rb
66
+ - lib/buildkite/models/user.rb
50
67
  - lib/buildkite/object.rb
51
- - lib/buildkite/objects/access_token.rb
52
- - lib/buildkite/objects/agent.rb
53
- - lib/buildkite/objects/annotation.rb
54
- - lib/buildkite/objects/artifact.rb
55
- - lib/buildkite/objects/artifact_download.rb
56
- - lib/buildkite/objects/build.rb
57
- - lib/buildkite/objects/emoji.rb
58
- - lib/buildkite/objects/job.rb
59
- - lib/buildkite/objects/job_env.rb
60
- - lib/buildkite/objects/job_log.rb
61
- - lib/buildkite/objects/organization.rb
62
- - lib/buildkite/objects/pipeline.rb
63
- - lib/buildkite/objects/user.rb
64
- - lib/buildkite/resource.rb
65
- - lib/buildkite/resources/access_token.rb
66
- - lib/buildkite/resources/agents.rb
67
- - lib/buildkite/resources/annotations.rb
68
- - lib/buildkite/resources/artifacts.rb
69
- - lib/buildkite/resources/builds.rb
70
- - lib/buildkite/resources/emojis.rb
71
- - lib/buildkite/resources/jobs.rb
72
- - lib/buildkite/resources/organizations.rb
73
- - lib/buildkite/resources/pipelines.rb
74
- - lib/buildkite/resources/user.rb
75
68
  - lib/buildkite/version.rb
76
69
  - lib/buildkiterb.rb
77
70
  homepage: https://deanpcmad.com
@@ -95,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
88
  - !ruby/object:Gem::Version
96
89
  version: '0'
97
90
  requirements: []
98
- rubygems_version: 3.4.6
91
+ rubygems_version: 3.5.7
99
92
  signing_key:
100
93
  specification_version: 4
101
94
  summary: A Ruby library for the Buildkite API
@@ -1,4 +0,0 @@
1
- module Buildkite
2
- class AccessToken < Object
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Buildkite
2
- class Agent < Object
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Buildkite
2
- class Annotation < Object
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Buildkite
2
- class Artifact < Object
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Buildkite
2
- class Build < Object
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Buildkite
2
- class Emoji < Object
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Buildkite
2
- class Job < Object
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Buildkite
2
- class Organization < Object
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Buildkite
2
- class Pipeline < Object
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Buildkite
2
- class User < Object
3
- end
4
- end
@@ -1,59 +0,0 @@
1
- module Buildkite
2
- class Resource
3
- attr_reader :client
4
-
5
- def initialize(client)
6
- @client = client
7
- end
8
-
9
- private
10
-
11
- def get_request(url, params: {}, headers: {})
12
- handle_response client.connection.get(url, params, headers)
13
- end
14
-
15
- def post_request(url, body:, headers: {})
16
- handle_response client.connection.post(url, body, headers)
17
- end
18
-
19
- def patch_request(url, body:, headers: {})
20
- handle_response client.connection.patch(url, body, headers)
21
- end
22
-
23
- def put_request(url, body:, headers: {})
24
- handle_response client.connection.put(url, body, headers)
25
- end
26
-
27
- def delete_request(url, params: {}, headers: {})
28
- handle_response client.connection.delete(url, params, headers)
29
- end
30
-
31
- def handle_response(response)
32
- case response.status
33
- when 400
34
- raise Error, "Error 400: Your request was malformed. '#{response.body["message"]}'"
35
- when 401
36
- raise Error, "Error 401: You did not supply valid authentication credentials. '#{response.body["message"]}'"
37
- when 403
38
- raise Error, "Error 403: You are not allowed to perform that action. '#{response.body["message"]}'"
39
- when 404
40
- raise Error, "Error 404: No results were found for your request. '#{response.body["message"]}'"
41
- when 409
42
- raise Error, "Error 409: Your request was a conflict. '#{response.body["message"]}'"
43
- when 422
44
- raise Error, "Error 422: Unprocessable Entity. '#{response.body["message"]}"
45
- when 429
46
- raise Error, "Error 429: Your request exceeded the API rate limit. '#{response.body["message"]}'"
47
- when 500
48
- raise Error, "Error 500: We were unable to perform the request due to server-side problems. '#{response.body["message"]}'"
49
- when 503
50
- raise Error, "Error 503: You have been rate limited for sending more than 20 requests per second. '#{response.body["message"]}'"
51
- when 204
52
- # 204 is a response for success
53
- return true
54
- end
55
-
56
- response
57
- end
58
- end
59
- end
@@ -1,13 +0,0 @@
1
- module Buildkite
2
- class AccessTokenResource < Resource
3
-
4
- def get
5
- AccessToken.new get_request("access-token").body
6
- end
7
-
8
- def revoke
9
- delete_request("access-token")
10
- end
11
-
12
- end
13
- end
@@ -1,18 +0,0 @@
1
- module Buildkite
2
- class AgentsResource < Resource
3
-
4
- def list(org:)
5
- response = get_request("organizations/#{org}/agents")
6
- Collection.from_response(response, type: Agent)
7
- end
8
-
9
- def get(org:, id:)
10
- Agent.new get_request("organizations/#{org}/agents/#{id}").body
11
- end
12
-
13
- def stop(org:, id:, **args)
14
- put_request("organizations/#{org}/agents/#{id}/stop", body: args)
15
- end
16
-
17
- end
18
- end
@@ -1,10 +0,0 @@
1
- module Buildkite
2
- class AnnotationsResource < Resource
3
-
4
- def list(org:, pipeline:, build:)
5
- response = get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/annotations")
6
- Collection.from_response(response, type: Annotation)
7
- end
8
-
9
- end
10
- end
@@ -1,27 +0,0 @@
1
- module Buildkite
2
- class ArtifactsResource < Resource
3
-
4
- def list(org:, pipeline:, build:, job: nil)
5
- if job
6
- response = get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/jobs/#{job}/artifacts")
7
- else
8
- response = get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/artifacts")
9
- end
10
-
11
- Collection.from_response(response, type: Artifact)
12
- end
13
-
14
- def get(org:, pipeline:, build:, job:, id:)
15
- Artifact.new get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/jobs/#{job}/artifacts/#{id}").body
16
- end
17
-
18
- def download(org:, pipeline:, build:, job:, id:)
19
- ArtifactDownload.new get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/jobs/#{job}/artifacts/#{id}/download").body
20
- end
21
-
22
- def delete(org:, pipeline:, build:, job:, id:)
23
- delete_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{build}/jobs/#{job}/artifacts/#{id}")
24
- end
25
-
26
- end
27
- end
@@ -1,36 +0,0 @@
1
- module Buildkite
2
- class BuildsResource < Resource
3
-
4
- def list(org: nil, pipeline: nil)
5
- if org && pipeline
6
- response = get_request("organizations/#{org}/pipelines/#{pipeline}/builds")
7
- elsif org
8
- response = get_request("organizations/#{org}/builds")
9
- else
10
- response = get_request("builds")
11
- end
12
-
13
- if response
14
- Collection.from_response(response, type: Build)
15
- end
16
- end
17
-
18
- def get(org:, pipeline:, number:)
19
- Build.new get_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}").body
20
- end
21
-
22
- def create(org:, pipeline:, commit:, branch:, **args)
23
- data = {commit: commit, branch: branch}
24
- Build.new post_request("organizations/#{org}/pipelines/#{pipeline}/builds", body: data.merge(args)).body
25
- end
26
-
27
- def cancel(org:, pipeline:, number:)
28
- Build.new put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/cancel", body: {}).body
29
- end
30
-
31
- def rebuild(org:, pipeline:, number:)
32
- Build.new put_request("organizations/#{org}/pipelines/#{pipeline}/builds/#{number}/rebuild", body: {}).body
33
- end
34
-
35
- end
36
- end
@@ -1,10 +0,0 @@
1
- module Buildkite
2
- class EmojisResource < Resource
3
-
4
- def list(org:)
5
- response = get_request("organizations/#{org}/emojis")
6
- Collection.from_response(response, type: Emoji)
7
- end
8
-
9
- end
10
- end