Skip to content

Commit e211013

Browse files
committed
Change repository deploy keys api to use new parser.
1 parent 63c687a commit e211013

2 files changed

Lines changed: 36 additions & 91 deletions

File tree

lib/github_api/client/repos/keys.rb

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,89 +7,75 @@ class Client::Repos::Keys < API
77

88
# List deploy keys
99
#
10-
# = Examples
11-
# github = Github.new
12-
# github.repos.keys.list 'user-name', 'repo-name'
13-
# github.repos.keys.list 'user-name', 'repo-name' { |key| ... }
10+
# @example
11+
# github = Github.new
12+
# github.repos.keys.list 'user-name', 'repo-name'
13+
# github.repos.keys.list 'user-name', 'repo-name' { |key| ... }
1414
#
15-
# keys = Github::Repos::Keys.new user: 'user-name', repo: 'repo-name'
16-
# keys.list
15+
# @example
16+
# keys = Github::Repos::Keys.new user: 'user-name', repo: 'repo-name'
17+
# keys.list
1718
#
19+
# @api public
1820
def list(*args)
19-
arguments(args, :required => [:user, :repo])
21+
arguments(args, required: [:user, :repo])
2022

21-
response = get_request("/repos/#{user}/#{repo}/keys", arguments.params)
23+
response = get_request("/repos/#{arguments.user}/#{arguments.repo}/keys", arguments.params)
2224
return response unless block_given?
2325
response.each { |el| yield el }
2426
end
2527
alias :all :list
2628

2729
# Get a key
2830
#
29-
# = Examples
30-
# github = Github.new
31-
# github.repos.keys.get 'user-name', 'repo-name', 'key-id'
31+
# @example
32+
# github = Github.new
33+
# github.repos.keys.get 'user-name', 'repo-name', 'key-id'
3234
#
35+
# @api public
3336
def get(*args)
34-
arguments(args, :required => [:user, :repo, :key_id])
37+
arguments(args, :required => [:user, :repo, :id])
3538

36-
get_request("/repos/#{user}/#{repo}/keys/#{key_id}", arguments.params)
39+
get_request("/repos/#{arguments.user}/#{arguments.repo}/keys/#{arguments.id}", arguments.params)
3740
end
3841
alias :find :get
3942

4043
# Create a key
4144
#
42-
# = Inputs
43-
# * <tt>:title</tt> - Required string.
44-
# * <tt>:key</tt> - Required string.
45+
# @param [Hash] params
46+
# @option params [String] :title
47+
# Required string.
48+
# @option params [String] :key
49+
# Required string.
4550
#
46-
# = Examples
47-
# github = Github.new
48-
# github.repos.keys.create 'user-name', 'repo-name',
49-
# "title" => "octocat@octomac",
50-
# "key" => "ssh-rsa AAA..."
51+
# @example
52+
# github = Github.new
53+
# github.repos.keys.create 'user-name', 'repo-name',
54+
# title: "octocat@octomac",
55+
# key: "ssh-rsa AAA..."
5156
#
57+
# @api public
5258
def create(*args)
53-
arguments(args, :required => [:user, :repo]) do
54-
sift VALID_KEY_OPTIONS
59+
arguments(args, required: [:user, :repo]) do
60+
permit VALID_KEY_OPTIONS
5561
assert_required VALID_KEY_OPTIONS
5662
end
5763

58-
post_request("/repos/#{user}/#{repo}/keys", arguments.params)
59-
end
60-
61-
# Edit a key
62-
#
63-
# = Inputs
64-
# * <tt>:title</tt> - Required string.
65-
# * <tt>:key</tt> - Required string.
66-
#
67-
# = Examples
68-
# github = Github.new
69-
# github.repos.keys.edit 'user-name', 'repo-name',
70-
# "title" => "octocat@octomac",
71-
# "key" => "ssh-rsa AAA..."
72-
#
73-
def edit(*args)
74-
arguments(args, :required => [:user, :repo, :key_id]) do
75-
sift VALID_KEY_OPTIONS
76-
end
77-
params = arguments.params
78-
79-
patch_request("/repos/#{user}/#{repo}/keys/#{key_id}", params)
64+
post_request("/repos/#{arguments.user}/#{arguments.repo}/keys", arguments.params)
8065
end
8166

8267
# Delete key
8368
#
84-
# = Examples
85-
# github = Github.new
86-
# github.repos.keys.delete 'user-name', 'repo-name', 'key-id'
69+
# @example
70+
# github = Github.new
71+
# github.repos.keys.delete 'user-name', 'repo-name', 'key-id'
8772
#
73+
# @api public
8874
def delete(*args)
89-
arguments(args, :required => [:user, :repo, :key_id])
75+
arguments(args, required: [:user, :repo, :id])
9076
params = arguments.params
9177

92-
delete_request("/repos/#{user}/#{repo}/keys/#{key_id}", params)
78+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/keys/#{arguments.id}", params)
9379
end
9480
end # Client::Repos::Keys
9581
end # Github

spec/github/client/repos/keys/edit_spec.rb

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)