Module: DroneCI::ReposAPI

Included in:
API
Defined in:
lib/drone-ci/api/repos.rb

Instance Method Summary collapse

Instance Method Details

#repo_chown(owner, repo) ⇒ Object

Lets a user assume ownership of a named repository.

Please note this api requires administrative access to the repository.

Reference: docs.drone.io/api/repos/repo_chown/



10
11
12
# File 'lib/drone-ci/api/repos.rb', line 10

def repo_chown(owner, repo)
  api.post("repos/#{owner}/#{repo}/chown")
end

#repo_create(owner, name) ⇒ Object Also known as: repo_enable

Registers a named repository with Drone.

Please note this api requires administrative access to the repository.

Reference: docs.drone.io/api/repos/repo_create/



34
35
36
# File 'lib/drone-ci/api/repos.rb', line 34

def repo_create(owner, name)
  api.post("repos/#{owner}/#{name}")
end

#repo_delete(owner, repo, remove: nil) ⇒ Object Also known as: repo_disable

Permanently deletes a repository. It cannot be undone.

Please note this api requires administrative access to the repository, and repository’s secrets and builds aren’t deleted.

Reference: docs.drone.io/api/repos/repo_delete/



19
20
21
22
23
24
25
# File 'lib/drone-ci/api/repos.rb', line 19

def repo_delete(owner, repo, remove: nil)
  api.delete("repos/#{owner}/#{repo}") do |request|
    { remove: remove }.compact.transform_keys(&:to_s).each do |key, value|
      request[key] = value
    end
  end
end

#repo_info(owner, repo) ⇒ Object

Retrieves the details of a repository.

Please note this api requires read access to the repository.

Reference: docs.drone.io/api/repos/repo_info/



45
46
47
# File 'lib/drone-ci/api/repos.rb', line 45

def repo_info(owner, repo)
  api.get("repos/#{owner}/#{repo}")
end

#repo_list(page: 1, per_page: 25) ⇒ Object

Returns repositories which are registered to Drone.

Reference: docs.drone.io/api/repos/repo_list/ the docs are wrong, they say this is at api/user/repos, but the source code says… github.com/harness/drone/blob/2d45d90cdd5cf2ec0e8dbcce2ea6bc340ce1e67e/handler/api/api.go#L173-L182



54
55
56
57
58
59
60
# File 'lib/drone-ci/api/repos.rb', line 54

def repo_list(page: 1, per_page: 25)
  api.get('repos') do |request|
    { page: page, per_page: per_page }.compact.transform_keys(&:to_s).each do |key, value|
      request[key] = value
    end
  end
end

#repo_repair(owner, repo) ⇒ Object

Recreates webhooks for your repository in your version control system (e.g GitHub). This can be used if you accidentally delete your webhooks.

Please note this api requires administrative access to the repository.

Reference: docs.drone.io/api/repos/repo_repair/



67
68
69
# File 'lib/drone-ci/api/repos.rb', line 67

def repo_repair(owner, repo)
  api.post("repos/#{owner}/#{repo}/repair")
end

#repo_update(owner, repo, **body) ⇒ Object

Updates a named repository.

Please note this api requires administrative access to the repository.

Reference: docs.drone.io/api/repos/repo_update/



76
77
78
# File 'lib/drone-ci/api/repos.rb', line 76

def repo_update(owner, repo, **body)
  api.patch("repos/#{owner}/#{repo}", body)
end