drone-ci 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32b1b7687a34f96c1f5fb7d9874e812d863a6908d4a71c0fe8ba9f7caf43be87
4
- data.tar.gz: 968b4778d5e9bbf0313c9d4cffe0065ef6bff6df0e6fd5f868424942e2002429
3
+ metadata.gz: 779d2b14f4b33e4a7b829a0544cbd45a7b63ee715907420e7114f0e659133930
4
+ data.tar.gz: 2b350dc61fa5f95c216ece72ed1f466700c2186f0790f5c3621cbe35fb662088
5
5
  SHA512:
6
- metadata.gz: e2724927033b7b82438f18dcdf80577a07be0aad50f72ba6f0ff0b1c1d62f91e3b215e8337a119b88d284442c614d5ae10fa3b8e266d149c4c667ba259d13718
7
- data.tar.gz: 2323cdc13b445b43b510dd3538bced63c77487606b6057b77ec3bb400860f213d77b9d6ad6dfa70f7540c62ceb4dbca19a06478798b643464eb41814047cf857
6
+ metadata.gz: 0b72a5def34bbd82bd2491811c13c48a4e6e8a859e018303c0a50db81b89d2af19ba6b18b16f0a5be7a4e1b304aee4696e6c06e9163ff9063461568b242f1343
7
+ data.tar.gz: f244b25d40d5fd0542793aeae1eb14dffe4885bc13f54bfeddfe5f226a573f6b493d0e53a837bbf78450b0ea9be58c5095e710c25b6dfd32504f39c043855ce2
@@ -38,6 +38,7 @@ jobs:
38
38
  files: |
39
39
  *.gem
40
40
  LICENSE.txt
41
+ CHANGELOG.md
41
42
  # - name: Publish to RubyGems
42
43
  # run: |
43
44
  # mkdir -p $HOME/.gem
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  .bundle
2
2
  Gemfile.lock
3
+ *.gem
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ 0.1.1
2
+
3
+ - (feature) Added documentation to API methods.
4
+ - (fix) removed required but unused argument from ReposAPI#repo_list
5
+ - (fix) ReposAPI#repo_create now actually uses the arguments given... :sweat_smile:
6
+
7
+ 0.1.0
8
+
9
+ - Initial Release
data/drone-ci.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  # gem.signing_key = File.expand_path ENV.fetch 'GEM_SIGNING_KEY'
14
14
 
15
15
  if ENV['HACKING']
16
- gem.version = '0.0.0-pre'
16
+ gem.version = '0.0.0'
17
17
  gem.files = Dir.glob('**')
18
18
  gem.executables = Dir.glob('bin/*')
19
19
  else
@@ -28,12 +28,12 @@ Gem::Specification.new do |gem|
28
28
  gem.add_runtime_dependency 'faraday', '~> 2.5', '>= 2.5.2'
29
29
  gem.add_runtime_dependency 'faraday-retry', '~> 2.0'
30
30
  gem.add_runtime_dependency 'httpx', '~> 0.21.0'
31
- gem.add_runtime_dependency 'octokit', '~> 5.4'
31
+ gem.add_runtime_dependency 'octokit', '~> 5.5'
32
32
 
33
33
  gem.add_development_dependency 'pry', '~> 0.14.1'
34
34
  gem.add_development_dependency 'pry-doc', '~> 1.3'
35
35
  gem.add_development_dependency 'rubocop', '~> 1.35'
36
- gem.add_development_dependency 'solargraph', '~> 0.45.0'
36
+ gem.add_development_dependency 'solargraph', '~> 0.46.0'
37
37
  gem.add_development_dependency 'yard', '~> 0.9.28'
38
38
  gem.metadata['rubygems_mfa_required'] = 'true'
39
39
  end
@@ -2,12 +2,20 @@
2
2
 
3
3
  module DroneCI
4
4
  module BuildsAPI
5
- # https://docs.drone.io/api/builds/build_approve/
5
+ # Approves a blocked build.
6
+ #
7
+ # Please note this api requires write access to the repository, and the request parameter {build} is not the build id but the build number.
8
+ #
9
+ # Reference: https://docs.drone.io/api/builds/build_approve/
6
10
  def build_approve(owner, repo, build)
7
11
  api.post("repos/#{owner}/#{repo}/builds/#{build}/approve")
8
12
  end
9
13
 
10
- # https://docs.drone.io/api/builds/build_create/
14
+ # Create a build using the latest commit for the specified branch.
15
+ #
16
+ # Please note the resulting build is created with event type `custom`.
17
+ #
18
+ # Reference: https://docs.drone.io/api/builds/build_create/
11
19
  def build_create(namespace, name, branch: nil, commit: nil, **params)
12
20
  api.post("repos/#{namespace}/#{name}/builds") do |request|
13
21
  { branch: branch, commit: commit }.merge(params).compact.transform_keys(&:to_s).each do |key, value|
@@ -16,27 +24,47 @@ module DroneCI
16
24
  end
17
25
  end
18
26
 
19
- # https://docs.drone.io/api/builds/build_decline/
27
+ # Declines a blocked build.
28
+ #
29
+ # Please note this api requires write access to the repository, and the request parameter {build} is not the build id but the build number.
30
+ #
31
+ # Reference: https://docs.drone.io/api/builds/build_decline/
20
32
  def build_decline(owner, repo, build)
21
33
  api.post("repos/#{owner}/#{repo}/builds/#{build}/decline")
22
34
  end
23
35
 
24
- # https://docs.drone.io/api/builds/build_info/
36
+ # Returns the specified repository build.
37
+ #
38
+ # Please note this api requires read access to the repository and the request parameter {build} is not the build id but the build number.
39
+ #
40
+ # Reference: https://docs.drone.io/api/builds/build_info/
25
41
  def build_info(owner, repo, build)
26
42
  api.get("repos/#{owner}/#{repo}/builds/#{build}")
27
43
  end
28
44
 
29
- # https://docs.drone.io/api/builds/build_list/
45
+ # Returns recent builds for the repository based on name.
46
+ #
47
+ # Please note this api requires read access to the repository.
48
+ #
49
+ # Reference: https://docs.drone.io/api/builds/build_list/
30
50
  def build_list(owner, repo)
31
51
  api.get("repos/#{owner}/#{repo}/builds")
32
52
  end
33
53
 
34
- # https://docs.drone.io/api/builds/build_logs/
54
+ # Please note this api requires read access to the repository.
55
+ #
56
+ # Reference: https://docs.drone.io/api/builds/build_logs/
35
57
  def build_logs(owner, repo, build, stage, step)
36
58
  api.get("repos/#{owner}/#{repo}/builds/#{build}/logs/#{stage}/#{step}")
37
59
  end
38
60
 
39
- # https://docs.drone.io/api/builds/build_promote/
61
+ # Promote the specified build number to the target environment.
62
+ #
63
+ # If given, additional (custom) parameters will be available to your pipeline steps as environment variables.
64
+ #
65
+ # Please note this api requires write access to the repository.
66
+ #
67
+ # Reference: https://docs.drone.io/api/builds/build_promote/
40
68
  def build_promote(owner, repo, build, target:, **params)
41
69
  api.post("repos/#{owner}/#{repo}/builds/#{build}") do |request|
42
70
  { target: target }.merge(params).compact.transform_keys(&:to_s).each do |key, value|
@@ -45,14 +73,22 @@ module DroneCI
45
73
  end
46
74
  end
47
75
 
48
- # https://docs.drone.io/api/builds/build_start/
76
+ # Restart the specified build.
77
+ #
78
+ # Please note this api requires read and write access to the repository and the request parameter {build} is not the build id but the build number.
79
+ #
80
+ # Reference: https://docs.drone.io/api/builds/build_start/
49
81
  def build_start(owner, repo, build)
50
82
  api.post("repos/#{owner}/#{repo}/builds/#{build}")
51
83
  end
52
84
 
53
85
  alias build_restart build_start
54
86
 
55
- # https://docs.drone.io/api/builds/build_stop/
87
+ # Stop the specified build.
88
+ #
89
+ # Please note this api requires administrative privileges and the request parameter {build} is not the build id but the build number.
90
+ #
91
+ # Reference: https://docs.drone.io/api/builds/build_stop/
56
92
  def build_stop(owner, repo, build)
57
93
  api.delete("repos/#{owner}/#{repo}/builds/#{build}")
58
94
  end
@@ -2,32 +2,56 @@
2
2
 
3
3
  module DroneCI
4
4
  module CronAPI
5
- # https://docs.drone.io/api/cron/cron_create/
5
+ # Create a new cron job.
6
+ #
7
+ # Please note this api requires write access to the repository.
8
+ #
9
+ # Reference: https://docs.drone.io/api/cron/cron_create/
6
10
  def cron_create(owner, repo, **body)
7
11
  api.post("repos/#{owner}/#{repo}/cron", body)
8
12
  end
9
13
 
10
- # https://docs.drone.io/api/cron/cron_delete/
14
+ # Deletes a cron job.
15
+ #
16
+ # Please note this api requires write access to the repository.
17
+ #
18
+ # Reference: https://docs.drone.io/api/cron/cron_delete/
11
19
  def cron_delete(owner, repo, name)
12
20
  api.delete("repos/#{owner}/#{repo}/cron/#{name}")
13
21
  end
14
22
 
15
- # https://docs.drone.io/api/cron/cron_info/
23
+ # Returns the named cron job.
24
+ #
25
+ # Please note this api requires write access to the repository.
26
+ #
27
+ # Reference: https://docs.drone.io/api/cron/cron_info/
16
28
  def cron_info(owner, repo, name)
17
29
  api.get("repos/#{owner}/#{repo}/cron/#{name}")
18
30
  end
19
31
 
20
- # https://docs.drone.io/api/cron/cron_list/
32
+ # Returns the cron job list.
33
+ #
34
+ # Please note this api requires write access to the repository.
35
+ #
36
+ # Reference: https://docs.drone.io/api/cron/cron_list/
21
37
  def cron_list(owner, repo)
22
38
  api.get("repos/#{owner}/#{repo}/cron")
23
39
  end
24
40
 
25
- # https://docs.drone.io/api/cron/cron_trigger/
41
+ # Trigger an existing cron task.
42
+ #
43
+ # Please note this api requires write access to the repository.
44
+ #
45
+ # Reference: https://docs.drone.io/api/cron/cron_trigger/
26
46
  def cron_trigger(owner, repo, name)
27
47
  api.post("repos/#{owner}/#{repo}/cron/#{name}")
28
48
  end
29
49
 
30
- # https://docs.drone.io/api/cron/cron_update/
50
+ # Updates the named cron job.
51
+ #
52
+ # Please note this api requires write access to the repository.
53
+ #
54
+ # Reference: https://docs.drone.io/api/cron/cron_update/
31
55
  def cron_update(owner, repo, name, **body)
32
56
  api.patch("repos/#{owner}/#{repo}/cron/#{name}", body)
33
57
  end
@@ -2,43 +2,69 @@
2
2
 
3
3
  module DroneCI
4
4
  module ReposAPI
5
- # https://docs.drone.io/api/repos/repo_chown/
5
+ # Lets a user assume ownership of a named repository.
6
+ #
7
+ # Please note this api requires administrative access to the repository.
8
+ #
9
+ # Reference: https://docs.drone.io/api/repos/repo_chown/
6
10
  def repo_chown(owner, repo)
7
11
  api.post("repos/#{owner}/#{repo}/chown")
8
12
  end
9
13
 
10
- # https://docs.drone.io/api/repos/repo_delete/
14
+ # Permanently deletes a repository. It cannot be undone.
15
+ #
16
+ # Please note this api requires administrative access to the repository, and repository’s secrets and builds aren’t deleted.
17
+ #
18
+ # Reference: https://docs.drone.io/api/repos/repo_delete/
11
19
  def repo_delete(owner, repo)
12
20
  api.delete("repos/#{owner}/#{repo}")
13
21
  end
14
22
 
15
23
  alias repo_disable repo_delete
16
24
 
17
- # https://docs.drone.io/api/repos/repo_create/
18
- def repo_create(owner, _name)
19
- api.post("repos/#{owner}/#{repo}")
25
+ # Registers a named repository with Drone.
26
+ #
27
+ # Please note this api requires administrative access to the repository.
28
+ #
29
+ # Reference: https://docs.drone.io/api/repos/repo_create/
30
+ def repo_create(owner, name)
31
+ api.post("repos/#{owner}/#{name}")
20
32
  end
21
33
 
22
34
  alias repo_enable repo_create
23
35
 
24
- # https://docs.drone.io/api/repos/repo_info/
36
+ # Retrieves the details of a repository.
37
+ #
38
+ # Please note this api requires read access to the repository.
39
+ #
40
+ # Reference: https://docs.drone.io/api/repos/repo_info/
25
41
  def repo_info(owner, repo)
26
42
  api.get("repos/#{owner}/#{repo}")
27
43
  end
28
44
 
29
- # https://docs.drone.io/api/repos/repo_list/
45
+ # Returns repositories which are registered to Drone.
46
+ #
47
+ # Reference: https://docs.drone.io/api/repos/repo_list/
30
48
  # the docs are wrong, they say this is at api/user/repos, but the source code says...
31
49
  # https://github.com/harness/drone/blob/2d45d90cdd5cf2ec0e8dbcce2ea6bc340ce1e67e/handler/api/api.go#L173-L182
32
- def repo_list(_owner)
50
+ def repo_list
33
51
  api.get('repos')
34
52
  end
35
53
 
36
- # https://docs.drone.io/api/repos/repo_repair/
54
+ # Recreates webhooks for your repository in your version control system (e.g GitHub). This can be used if you accidentally delete your webhooks.
55
+ #
56
+ # Please note this api requires administrative access to the repository.
57
+ #
58
+ # Reference: https://docs.drone.io/api/repos/repo_repair/
37
59
  def repo_repair(owner, repo)
38
60
  api.post("repos/#{owner}/#{repo}/repair")
39
61
  end
40
62
 
41
- # https://docs.drone.io/api/repos/repo_update/
63
+ # Updates a named repository.
64
+ #
65
+ # Please note this api requires administrative access to the repository.
66
+ #
67
+ # Reference: https://docs.drone.io/api/repos/repo_update/
42
68
  def repo_update(owner, repo, **body)
43
69
  api.patch("repos/#{owner}/#{repo}", body)
44
70
  end
@@ -2,27 +2,47 @@
2
2
 
3
3
  module DroneCI
4
4
  module SecretsAPI
5
- # https://docs.drone.io/api/secrets/secret_create/
5
+ # Create a new repository secret.
6
+ #
7
+ # Please note this api requires write access to the repository.
8
+ #
9
+ # Reference: https://docs.drone.io/api/secrets/secret_create/
6
10
  def secret_create(owner, repo, **body)
7
11
  api.post("repos/#{owner}/#{repo}/secrets", body)
8
12
  end
9
13
 
10
- # https://docs.drone.io/api/secrets/secret_delete/
14
+ # Deletes a repository secret.
15
+ #
16
+ # Please note this api requires write access to the repository, and the request parameter {secret} is not the secret’s id but secret name.
17
+ #
18
+ # Reference: https://docs.drone.io/api/secrets/secret_delete/
11
19
  def secret_delete(owner, repo, secret)
12
20
  api.post("repos/#{owner}/#{repo}/secrets/#{secret}")
13
21
  end
14
22
 
15
- # https://docs.drone.io/api/secrets/secret_info/
23
+ # Returns the repository secret.
24
+ #
25
+ # Please note this api requires write access to the repository, and the request parameter {secret} is not the secret’s id but secret name.
26
+ #
27
+ # Reference: https://docs.drone.io/api/secrets/secret_info/
16
28
  def secret_info(owner, repo, secret)
17
29
  api.get("repos/#{owner}/#{repo}/secrets/#{secret}")
18
30
  end
19
31
 
20
- # https://docs.drone.io/api/secrets/secret_list/
32
+ # Returns the repository secret list.
33
+ #
34
+ # Please note this api requires write access to the repository.
35
+ #
36
+ # Reference: https://docs.drone.io/api/secrets/secret_list/
21
37
  def secret_list(owner, repo)
22
38
  api.get("repos/#{owner}/#{repo}/secrets")
23
39
  end
24
40
 
25
- # https://docs.drone.io/api/secrets/secret_update/
41
+ # Updates the specified repository secret.
42
+ #
43
+ # Please note this api requires write access to the repository, and the request parameter {secret} is not the secret’s id but secret name.
44
+ #
45
+ # Reference: https://docs.drone.io/api/secrets/secret_update/
26
46
  def secret_update(owner, repo, secret, **body)
27
47
  api.patch("repos/#{owner}/#{repo}/secrets/#{secret}", body)
28
48
  end
@@ -2,27 +2,47 @@
2
2
 
3
3
  module DroneCI
4
4
  module TemplatesAPI
5
- # https://docs.drone.io/api/templates/template_create/
5
+ # Create a new template.
6
+ #
7
+ # Please note this api requires write access to the repository.
8
+ #
9
+ # Reference: https://docs.drone.io/api/templates/template_create/
6
10
  def template_create(namespace, **body)
7
11
  api.post("templates/#{namespace}", body)
8
12
  end
9
13
 
10
- # https://docs.drone.io/api/templates/template_delete/
14
+ # Deletes a template.
15
+ #
16
+ # Please note this api requires write access to the repository.
17
+ #
18
+ # Reference: https://docs.drone.io/api/templates/template_delete/
11
19
  def template_delete(namespace, name)
12
20
  api.delete("templates/#{namespace}/#{name}")
13
21
  end
14
22
 
15
- # https://docs.drone.io/api/templates/template_info/
23
+ # Returns the template.
24
+ #
25
+ # Please note this api requires write access to the repository.
26
+ #
27
+ # Reference: https://docs.drone.io/api/templates/template_info/
16
28
  def template_info(namespace, name)
17
29
  api.get("templates/#{namespace}/#{name}")
18
30
  end
19
31
 
20
- # https://docs.drone.io/api/templates/template_list/
32
+ # Returns the organization template list.
33
+ #
34
+ # Please note this api requires write access to the repository.
35
+ #
36
+ # Reference: https://docs.drone.io/api/templates/template_list/
21
37
  def template_list(namespace)
22
38
  api.get("templates/#{namespace}")
23
39
  end
24
40
 
25
- # https://docs.drone.io/api/templates/template_update/
41
+ # Updates the specified repository secret.
42
+ #
43
+ # Please note this api requires write access to the repository, and the request parameter {secret} is not the secret’s id but secret name.
44
+ #
45
+ # Reference: https://docs.drone.io/api/templates/template_update/
26
46
  def template_update(namespace, name, **body)
27
47
  api.patch("templates/#{namespace}/#{name}", body)
28
48
  end
@@ -2,17 +2,25 @@
2
2
 
3
3
  module DroneCI
4
4
  module UserAPI
5
- # https://docs.drone.io/api/user/user_builds/
5
+ # Returns the currently authenticated user’s build feed.
6
+ #
7
+ # Reference: https://docs.drone.io/api/user/user_builds/
6
8
  def user_builds
7
9
  api.get('user/builds')
8
10
  end
9
11
 
10
- # https://docs.drone.io/api/user/user_info/
12
+ # Returns the currently authenticated user.
13
+ #
14
+ # Reference: https://docs.drone.io/api/user/user_info/
11
15
  def user_info
12
16
  api.get('user')
13
17
  end
14
18
 
15
- # https://docs.drone.io/api/user/user_repos/
19
+ # Returns the currently authenticated user’s repository list.
20
+ #
21
+ # Optionally, include the latest build for each active repository.
22
+ #
23
+ # Reference: https://docs.drone.io/api/user/user_repos/
16
24
  def user_repos(latest: nil)
17
25
  api.get('user/repos') do |request|
18
26
  { latest: latest }.compact.each do |key, value|
@@ -21,7 +29,9 @@ module DroneCI
21
29
  end
22
30
  end
23
31
 
24
- # https://docs.drone.io/api/user/user_sync/
32
+ # Synchronize the currently authenticated user’s repository list.
33
+ #
34
+ # Reference: https://docs.drone.io/api/user/user_sync/
25
35
  def user_sync
26
36
  api.post('user/repos')
27
37
  end
@@ -2,27 +2,47 @@
2
2
 
3
3
  module DroneCI
4
4
  module UsersAPI
5
- # https://docs.drone.io/api/users/users_create/
5
+ # Creates a user.
6
+ #
7
+ # Please note this api requires administrative privileges.
8
+ #
9
+ # Reference: https://docs.drone.io/api/users/users_create/
6
10
  def users_create(**body)
7
11
  api.post('users', body)
8
12
  end
9
13
 
10
- # https://docs.drone.io/api/users/users_delete/
14
+ # Deletes a user.
15
+ #
16
+ # Please note this api requires administrative privileges.
17
+ #
18
+ # Reference: https://docs.drone.io/api/users/users_delete/
11
19
  def users_delete(login)
12
20
  api.delete("users/#{login}")
13
21
  end
14
22
 
15
- # https://docs.drone.io/api/users/users_info/
23
+ # Returns information about the named registered user.
24
+ #
25
+ # Please note this api requires administrative privileges.
26
+ #
27
+ # Reference: https://docs.drone.io/api/users/users_info/
16
28
  def users_info(login)
17
29
  api.get("users/#{login}")
18
30
  end
19
31
 
20
- # https://docs.drone.io/api/users/users_list/
32
+ # Returns a list of all registered users.
33
+ #
34
+ # Please note this api requires administrative privileges.
35
+ #
36
+ # Reference: https://docs.drone.io/api/users/users_list/
21
37
  def users_list
22
38
  api.get('users')
23
39
  end
24
40
 
25
- # https://docs.drone.io/api/users/users_update/
41
+ # Updates the specified user.
42
+ #
43
+ # Please note this api requires administrative privileges.
44
+ #
45
+ # Reference: https://docs.drone.io/api/users/users_update/
26
46
  def users_update(login, **body)
27
47
  api.patch("users/#{login}", body)
28
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drone-ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Olstrom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-10 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '5.4'
67
+ version: '5.5'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '5.4'
74
+ version: '5.5'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: pry
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +120,14 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: 0.45.0
123
+ version: 0.46.0
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: 0.45.0
130
+ version: 0.46.0
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: yard
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -154,6 +154,7 @@ files:
154
154
  - ".github/workflows/gem-push.yml"
155
155
  - ".gitignore"
156
156
  - ".rubocop.yml"
157
+ - CHANGELOG.md
157
158
  - Gemfile
158
159
  - LICENSE.txt
159
160
  - README.md