github_api2 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +770 -0
- data/LICENSE.txt +20 -0
- data/README.md +741 -0
- data/lib/github_api2/api/actions.rb +60 -0
- data/lib/github_api2/api/arguments.rb +253 -0
- data/lib/github_api2/api/config/property.rb +30 -0
- data/lib/github_api2/api/config/property_set.rb +120 -0
- data/lib/github_api2/api/config.rb +105 -0
- data/lib/github_api2/api/factory.rb +33 -0
- data/lib/github_api2/api.rb +398 -0
- data/lib/github_api2/authorization.rb +75 -0
- data/lib/github_api2/client/activity/events.rb +233 -0
- data/lib/github_api2/client/activity/feeds.rb +50 -0
- data/lib/github_api2/client/activity/notifications.rb +181 -0
- data/lib/github_api2/client/activity/starring.rb +130 -0
- data/lib/github_api2/client/activity/watching.rb +176 -0
- data/lib/github_api2/client/activity.rb +31 -0
- data/lib/github_api2/client/authorizations/app.rb +98 -0
- data/lib/github_api2/client/authorizations.rb +142 -0
- data/lib/github_api2/client/emojis.rb +19 -0
- data/lib/github_api2/client/gists/comments.rb +100 -0
- data/lib/github_api2/client/gists.rb +289 -0
- data/lib/github_api2/client/git_data/blobs.rb +51 -0
- data/lib/github_api2/client/git_data/commits.rb +101 -0
- data/lib/github_api2/client/git_data/references.rb +150 -0
- data/lib/github_api2/client/git_data/tags.rb +95 -0
- data/lib/github_api2/client/git_data/trees.rb +113 -0
- data/lib/github_api2/client/git_data.rb +31 -0
- data/lib/github_api2/client/gitignore.rb +57 -0
- data/lib/github_api2/client/issues/assignees.rb +77 -0
- data/lib/github_api2/client/issues/comments.rb +146 -0
- data/lib/github_api2/client/issues/events.rb +50 -0
- data/lib/github_api2/client/issues/labels.rb +189 -0
- data/lib/github_api2/client/issues/milestones.rb +146 -0
- data/lib/github_api2/client/issues.rb +248 -0
- data/lib/github_api2/client/markdown.rb +62 -0
- data/lib/github_api2/client/meta.rb +19 -0
- data/lib/github_api2/client/orgs/hooks.rb +182 -0
- data/lib/github_api2/client/orgs/members.rb +142 -0
- data/lib/github_api2/client/orgs/memberships.rb +131 -0
- data/lib/github_api2/client/orgs/projects.rb +57 -0
- data/lib/github_api2/client/orgs/teams.rb +407 -0
- data/lib/github_api2/client/orgs.rb +127 -0
- data/lib/github_api2/client/projects/cards.rb +158 -0
- data/lib/github_api2/client/projects/columns.rb +146 -0
- data/lib/github_api2/client/projects.rb +83 -0
- data/lib/github_api2/client/pull_requests/comments.rb +140 -0
- data/lib/github_api2/client/pull_requests/reviews.rb +158 -0
- data/lib/github_api2/client/pull_requests.rb +195 -0
- data/lib/github_api2/client/repos/branches/protections.rb +75 -0
- data/lib/github_api2/client/repos/branches.rb +48 -0
- data/lib/github_api2/client/repos/collaborators.rb +84 -0
- data/lib/github_api2/client/repos/comments.rb +125 -0
- data/lib/github_api2/client/repos/commits.rb +80 -0
- data/lib/github_api2/client/repos/contents.rb +263 -0
- data/lib/github_api2/client/repos/deployments.rb +138 -0
- data/lib/github_api2/client/repos/downloads.rb +62 -0
- data/lib/github_api2/client/repos/forks.rb +50 -0
- data/lib/github_api2/client/repos/hooks.rb +214 -0
- data/lib/github_api2/client/repos/invitations.rb +41 -0
- data/lib/github_api2/client/repos/keys.rb +104 -0
- data/lib/github_api2/client/repos/merging.rb +47 -0
- data/lib/github_api2/client/repos/pages.rb +48 -0
- data/lib/github_api2/client/repos/projects.rb +62 -0
- data/lib/github_api2/client/repos/pub_sub_hubbub.rb +133 -0
- data/lib/github_api2/client/repos/releases/assets.rb +136 -0
- data/lib/github_api2/client/repos/releases/tags.rb +24 -0
- data/lib/github_api2/client/repos/releases.rb +189 -0
- data/lib/github_api2/client/repos/statistics.rb +89 -0
- data/lib/github_api2/client/repos/statuses.rb +91 -0
- data/lib/github_api2/client/repos.rb +473 -0
- data/lib/github_api2/client/say.rb +25 -0
- data/lib/github_api2/client/scopes.rb +46 -0
- data/lib/github_api2/client/search/legacy.rb +111 -0
- data/lib/github_api2/client/search.rb +133 -0
- data/lib/github_api2/client/users/emails.rb +65 -0
- data/lib/github_api2/client/users/followers.rb +115 -0
- data/lib/github_api2/client/users/keys.rb +104 -0
- data/lib/github_api2/client/users.rb +117 -0
- data/lib/github_api2/client.rb +77 -0
- data/lib/github_api2/configuration.rb +70 -0
- data/lib/github_api2/connection.rb +82 -0
- data/lib/github_api2/constants.rb +61 -0
- data/lib/github_api2/core_ext/array.rb +25 -0
- data/lib/github_api2/core_ext/hash.rb +91 -0
- data/lib/github_api2/deprecation.rb +39 -0
- data/lib/github_api2/error/client_error.rb +89 -0
- data/lib/github_api2/error/service_error.rb +223 -0
- data/lib/github_api2/error.rb +32 -0
- data/lib/github_api2/ext/faraday.rb +40 -0
- data/lib/github_api2/mash.rb +7 -0
- data/lib/github_api2/middleware.rb +37 -0
- data/lib/github_api2/mime_type.rb +33 -0
- data/lib/github_api2/normalizer.rb +23 -0
- data/lib/github_api2/null_encoder.rb +25 -0
- data/lib/github_api2/page_iterator.rb +138 -0
- data/lib/github_api2/page_links.rb +63 -0
- data/lib/github_api2/paged_request.rb +42 -0
- data/lib/github_api2/pagination.rb +115 -0
- data/lib/github_api2/parameter_filter.rb +35 -0
- data/lib/github_api2/params_hash.rb +115 -0
- data/lib/github_api2/rate_limit.rb +25 -0
- data/lib/github_api2/request/basic_auth.rb +36 -0
- data/lib/github_api2/request/jsonize.rb +54 -0
- data/lib/github_api2/request/oauth2.rb +45 -0
- data/lib/github_api2/request/verbs.rb +63 -0
- data/lib/github_api2/request.rb +84 -0
- data/lib/github_api2/response/atom_parser.rb +22 -0
- data/lib/github_api2/response/follow_redirects.rb +140 -0
- data/lib/github_api2/response/header.rb +87 -0
- data/lib/github_api2/response/jsonize.rb +28 -0
- data/lib/github_api2/response/mashify.rb +24 -0
- data/lib/github_api2/response/raise_error.rb +22 -0
- data/lib/github_api2/response/xmlize.rb +28 -0
- data/lib/github_api2/response.rb +48 -0
- data/lib/github_api2/response_wrapper.rb +161 -0
- data/lib/github_api2/ssl_certs/cacerts.pem +2183 -0
- data/lib/github_api2/utils/url.rb +63 -0
- data/lib/github_api2/validations/format.rb +26 -0
- data/lib/github_api2/validations/presence.rb +32 -0
- data/lib/github_api2/validations/required.rb +21 -0
- data/lib/github_api2/validations/token.rb +41 -0
- data/lib/github_api2/validations.rb +22 -0
- data/lib/github_api2/version.rb +5 -0
- data/lib/github_api2.rb +92 -0
- metadata +363 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Meta < API
|
|
7
|
+
# Get meta information about GitHub.com, the service.
|
|
8
|
+
#
|
|
9
|
+
# @example
|
|
10
|
+
# Github.meta.get
|
|
11
|
+
#
|
|
12
|
+
# @api public
|
|
13
|
+
def get(*args)
|
|
14
|
+
arguments(*args)
|
|
15
|
+
|
|
16
|
+
get_request("/meta", arguments.params)
|
|
17
|
+
end
|
|
18
|
+
end # Client::Meta
|
|
19
|
+
end # Github
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
# The Organizations Hooks API manages the post-receive web and
|
|
7
|
+
# service hooks for an organization.
|
|
8
|
+
class Client::Orgs::Hooks < API
|
|
9
|
+
|
|
10
|
+
REQUIRED_PARAMS = %w( name config ).freeze # :nodoc:
|
|
11
|
+
|
|
12
|
+
# List organization hooks
|
|
13
|
+
#
|
|
14
|
+
# @see https://developer.github.com/v3/orgs/hooks/#list-hooks
|
|
15
|
+
#
|
|
16
|
+
# @example
|
|
17
|
+
# github = Github.new
|
|
18
|
+
# github.orgs.hooks.list 'org-name'
|
|
19
|
+
# github.orgs.hooks.list 'org-name' { |hook| ... }
|
|
20
|
+
#
|
|
21
|
+
# @api public
|
|
22
|
+
def list(*args)
|
|
23
|
+
arguments(args, required: [:org_name])
|
|
24
|
+
|
|
25
|
+
response = get_request("/orgs/#{arguments.org_name}/hooks", arguments.params)
|
|
26
|
+
return response unless block_given?
|
|
27
|
+
response.each { |el| yield el }
|
|
28
|
+
end
|
|
29
|
+
alias_method :all, :list
|
|
30
|
+
|
|
31
|
+
# Get a single hook
|
|
32
|
+
#
|
|
33
|
+
# @see https://developer.github.com/v3/orgs/hooks/#get-single-hook
|
|
34
|
+
#
|
|
35
|
+
# @example
|
|
36
|
+
# github = Github.new
|
|
37
|
+
# github.orgs.hooks.get 'org-name', 'hook-id'
|
|
38
|
+
#
|
|
39
|
+
# @api public
|
|
40
|
+
def get(*args)
|
|
41
|
+
arguments(args, required: [:org_name, :id])
|
|
42
|
+
|
|
43
|
+
get_request("/orgs/#{arguments.org_name}/hooks/#{arguments.id}",
|
|
44
|
+
arguments.params)
|
|
45
|
+
end
|
|
46
|
+
alias_method :find, :get
|
|
47
|
+
|
|
48
|
+
# Create a hook
|
|
49
|
+
#
|
|
50
|
+
# @see https://developer.github.com/v3/orgs/hooks/#create-a-hook
|
|
51
|
+
#
|
|
52
|
+
# @param [Hash] params
|
|
53
|
+
# @input params [String] :name
|
|
54
|
+
# Required. The name of the service that is being called.
|
|
55
|
+
# @input params [Hash] :config
|
|
56
|
+
# Required. Key/value pairs to provide settings for this hook.
|
|
57
|
+
# These settings vary between the services and are defined in
|
|
58
|
+
# the github-services repository. Booleans are stored internally
|
|
59
|
+
# as "1" for true, and "0" for false. Any JSON true/false values
|
|
60
|
+
# will be converted automatically.
|
|
61
|
+
# @input params [Array] :events
|
|
62
|
+
# Determines what events the hook is triggered for. Default: ["push"]
|
|
63
|
+
# @input params [Boolean] :active
|
|
64
|
+
# Determines whether the hook is actually triggered on pushes.
|
|
65
|
+
#
|
|
66
|
+
# To create a webhook, the following fields are required by the config:
|
|
67
|
+
#
|
|
68
|
+
# @input config [String] :url
|
|
69
|
+
# A required string defining the URL to which the payloads
|
|
70
|
+
# will be delivered.
|
|
71
|
+
# @input config [String] :content_type
|
|
72
|
+
# An optional string defining the media type used to serialize
|
|
73
|
+
# the payloads. Supported values include json and form.
|
|
74
|
+
# The default is form.
|
|
75
|
+
# @input config [String] :secret
|
|
76
|
+
# An optional string that’s passed with the HTTP requests as
|
|
77
|
+
# an X-Hub-Signature header. The value of this header is
|
|
78
|
+
# computed as the HMAC hex digest of the body,
|
|
79
|
+
# using the secret as the key.
|
|
80
|
+
# @input config [String] :insecure_ssl
|
|
81
|
+
# An optional string that determines whether the SSL certificate
|
|
82
|
+
# of the host for url will be verified when delivering payloads.
|
|
83
|
+
# Supported values include "0" (verification is performed) and
|
|
84
|
+
# "1" (verification is not performed). The default is "0".or instance, if the library doesn't get updated to permit a given parameter the api call won't work, however if we skip permission all together, the endpoint should always work provided the actual resource path doesn't change. I'm in the process of completely removing the permit functionality.
|
|
85
|
+
#
|
|
86
|
+
# @example
|
|
87
|
+
# github = Github.new
|
|
88
|
+
# github.orgs.hooks.create 'org-name',
|
|
89
|
+
# name: "web",
|
|
90
|
+
# active: true,
|
|
91
|
+
# config: {
|
|
92
|
+
# url: "http://something.com/webhook"
|
|
93
|
+
# }
|
|
94
|
+
# }
|
|
95
|
+
#
|
|
96
|
+
# @api public
|
|
97
|
+
def create(*args)
|
|
98
|
+
arguments(args, required: [:org_name]) do
|
|
99
|
+
assert_required REQUIRED_PARAMS
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
post_request("/orgs/#{arguments.org_name}/hooks", arguments.params)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Edit a hook
|
|
106
|
+
#
|
|
107
|
+
# @see https://developer.github.com/v3/orgs/hooks/#edit-a-hook
|
|
108
|
+
#
|
|
109
|
+
# @param [Hash] params
|
|
110
|
+
# @input params [Hash] :config
|
|
111
|
+
# Required. Key/value pairs to provide settings for this hook.
|
|
112
|
+
# These settings vary between the services and are defined in
|
|
113
|
+
# the github-services repository. Booleans are stored internally
|
|
114
|
+
# as "1" for true, and "0" for false. Any JSON true/false values
|
|
115
|
+
# will be converted automatically.
|
|
116
|
+
# @input params [Array] :events
|
|
117
|
+
# Determines what events the hook is triggered for. Default: ["push"]
|
|
118
|
+
# @input params [Array] :add_events
|
|
119
|
+
# Determines a list of events to be added to the list of events
|
|
120
|
+
# that the Hook triggers for.
|
|
121
|
+
# @input params [Array] :remove_events
|
|
122
|
+
# Determines a list of events to be removed from the list of
|
|
123
|
+
# events that the Hook triggers for.
|
|
124
|
+
# @input params [Boolean] :active
|
|
125
|
+
# Determines whether the hook is actually triggered on pushes.
|
|
126
|
+
#
|
|
127
|
+
# @example
|
|
128
|
+
# github = Github.new
|
|
129
|
+
# github.orgs.hooks.edit 'org-name', 'hook-id',
|
|
130
|
+
# "name" => "campfire",
|
|
131
|
+
# "active" => true,
|
|
132
|
+
# "config" => {
|
|
133
|
+
# "subdomain" => "github",
|
|
134
|
+
# "room" => "Commits",
|
|
135
|
+
# "token" => "abc123"
|
|
136
|
+
# }
|
|
137
|
+
#
|
|
138
|
+
# @api public
|
|
139
|
+
def edit(*args)
|
|
140
|
+
arguments(args, required: [:org_name, :id]) do
|
|
141
|
+
assert_required REQUIRED_PARAMS
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
patch_request("/orgs/#{arguments.org_name}/hooks/#{arguments.id}",
|
|
145
|
+
arguments.params)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Ping a hook
|
|
149
|
+
#
|
|
150
|
+
# This will trigger a ping event to be sent to the hook.
|
|
151
|
+
#
|
|
152
|
+
# @see https://developer.github.com/v3/orgs/hooks/#ping-a-hook
|
|
153
|
+
#
|
|
154
|
+
# @example
|
|
155
|
+
# github = Github.new
|
|
156
|
+
# github.orgs.hooks.ping 'org-name', 'hook-id'
|
|
157
|
+
#
|
|
158
|
+
# @api public
|
|
159
|
+
def ping(*args)
|
|
160
|
+
arguments(args, required: [:org_name, :id])
|
|
161
|
+
|
|
162
|
+
post_request("/orgs/#{arguments.org_name}/hooks/#{arguments.id}/pings",
|
|
163
|
+
arguments.params)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Delete a hook
|
|
167
|
+
#
|
|
168
|
+
# @see https://developer.github.com/v3/orgs/hooks/#delete-a-hook
|
|
169
|
+
#
|
|
170
|
+
# @example
|
|
171
|
+
# github = Github.new
|
|
172
|
+
# github.orgs.hooks.delete 'org-name', 'hook-id'
|
|
173
|
+
#
|
|
174
|
+
# @api public
|
|
175
|
+
def delete(*args)
|
|
176
|
+
arguments(args, required: [:org_name, :id])
|
|
177
|
+
|
|
178
|
+
delete_request("/orgs/#{arguments.org_name}/hooks/#{arguments.id}",
|
|
179
|
+
arguments.params)
|
|
180
|
+
end
|
|
181
|
+
end # Client::Orgs::Hooks
|
|
182
|
+
end # Github
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Orgs::Members < API
|
|
7
|
+
# List members
|
|
8
|
+
#
|
|
9
|
+
# List all users who are members of an organization. A member is a user
|
|
10
|
+
# that belongs to at least 1 team in the organization.
|
|
11
|
+
# If the authenticated user is also a member of this organization then
|
|
12
|
+
# both concealed and public members will be returned.
|
|
13
|
+
# Otherwise only public members are returned.
|
|
14
|
+
#
|
|
15
|
+
# @see https://developer.github.com/v3/orgs/members/#members-list
|
|
16
|
+
#
|
|
17
|
+
# @param [Hash] params
|
|
18
|
+
# @option params [String] :filter
|
|
19
|
+
# Filter members returned in the list. Can be one of:
|
|
20
|
+
# * 2fa_disabled: Members without two-factor authentication enabled.
|
|
21
|
+
# Available for owners of organizations with private repositories.
|
|
22
|
+
# * all: All members the authenticated user can see.
|
|
23
|
+
# Default: all
|
|
24
|
+
# @option params [String] :role
|
|
25
|
+
# Filter members returned by their role. Can be one of:
|
|
26
|
+
# * all: All members of the organization, regardless of role.
|
|
27
|
+
# * admin: Organization owners.
|
|
28
|
+
# * member: Non-owner organization members.
|
|
29
|
+
#
|
|
30
|
+
# @example
|
|
31
|
+
# github = Github.new
|
|
32
|
+
# github.orgs.members.list 'org-name'
|
|
33
|
+
# github.orgs.members.list 'org-name' { |memb| ... }
|
|
34
|
+
#
|
|
35
|
+
# List public members
|
|
36
|
+
#
|
|
37
|
+
# @see https://developer.github.com/v3/orgs/members/#public-members-list
|
|
38
|
+
#
|
|
39
|
+
# Members of an organization can choose to have their
|
|
40
|
+
# membership publicized or not.
|
|
41
|
+
#
|
|
42
|
+
# @example
|
|
43
|
+
# github = Github.new
|
|
44
|
+
# github.orgs.members.list 'org-name', public: true
|
|
45
|
+
# github.orgs.members.list 'org-name', public: true { |memb| ... }
|
|
46
|
+
#
|
|
47
|
+
# @api public
|
|
48
|
+
def list(*args)
|
|
49
|
+
params = arguments(args, required: [:org_name]).params
|
|
50
|
+
org_name = arguments.org_name
|
|
51
|
+
|
|
52
|
+
response = if params.delete('public')
|
|
53
|
+
get_request("/orgs/#{org_name}/public_members", params)
|
|
54
|
+
else
|
|
55
|
+
get_request("/orgs/#{org_name}/members", params)
|
|
56
|
+
end
|
|
57
|
+
return response unless block_given?
|
|
58
|
+
response.each { |el| yield el }
|
|
59
|
+
end
|
|
60
|
+
alias_method :all, :list
|
|
61
|
+
|
|
62
|
+
# Check if user is, publicly or privately, a member of an organization
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# github = Github.new
|
|
66
|
+
# github.orgs.members.member? 'org-name', 'member-name'
|
|
67
|
+
#
|
|
68
|
+
# Check if a user is a public member of an organization
|
|
69
|
+
#
|
|
70
|
+
# @example
|
|
71
|
+
# github = Github.new
|
|
72
|
+
# github.orgs.members.member? 'org-name', 'member-name', public: true
|
|
73
|
+
#
|
|
74
|
+
# @api public
|
|
75
|
+
def member?(*args)
|
|
76
|
+
params = arguments(args, required: [:org_name, :user]).params
|
|
77
|
+
org_name = arguments.org_name
|
|
78
|
+
user = arguments.user
|
|
79
|
+
|
|
80
|
+
response = if params.delete('public')
|
|
81
|
+
get_request("/orgs/#{org_name}/public_members/#{user}", params)
|
|
82
|
+
else
|
|
83
|
+
get_request("/orgs/#{org_name}/members/#{user}", params)
|
|
84
|
+
end
|
|
85
|
+
response.status == 204
|
|
86
|
+
rescue Github::Error::NotFound
|
|
87
|
+
false
|
|
88
|
+
end
|
|
89
|
+
# Remove a member
|
|
90
|
+
#
|
|
91
|
+
# Removing a user from this list will remove them from all teams and
|
|
92
|
+
# they will no longer have any access to the organization's repositories.
|
|
93
|
+
#
|
|
94
|
+
# @see https://developer.github.com/v3/orgs/members/#remove-a-member
|
|
95
|
+
#
|
|
96
|
+
# @example
|
|
97
|
+
# github = Github.new
|
|
98
|
+
# github.orgs.members.remove 'org-name', 'member-name'
|
|
99
|
+
#
|
|
100
|
+
# @api public
|
|
101
|
+
def delete(*args)
|
|
102
|
+
arguments(args, required: [:org_name, :user])
|
|
103
|
+
|
|
104
|
+
delete_request("/orgs/#{arguments.org_name}/members/#{arguments.user}",
|
|
105
|
+
arguments.params)
|
|
106
|
+
end
|
|
107
|
+
alias_method :remove, :delete
|
|
108
|
+
|
|
109
|
+
# Publicize a user's membership
|
|
110
|
+
#
|
|
111
|
+
# @see https://developer.github.com/v3/orgs/members/#publicize-a-users-membership
|
|
112
|
+
#
|
|
113
|
+
# @example
|
|
114
|
+
# github = Github.new oauth_token: '...'
|
|
115
|
+
# github.orgs.members.publicize 'org-name', 'member-name'
|
|
116
|
+
#
|
|
117
|
+
# @api public
|
|
118
|
+
def publicize(*args)
|
|
119
|
+
arguments(args, required: [:org_name, :user])
|
|
120
|
+
|
|
121
|
+
put_request("/orgs/#{arguments.org_name}/public_members/#{arguments.user}", arguments.params)
|
|
122
|
+
end
|
|
123
|
+
alias_method :make_public, :publicize
|
|
124
|
+
alias_method :publicize_membership, :publicize
|
|
125
|
+
|
|
126
|
+
# Conceal a user's membership
|
|
127
|
+
#
|
|
128
|
+
# @see https://developer.github.com/v3/orgs/members/#conceal-a-users-membership
|
|
129
|
+
#
|
|
130
|
+
# @example
|
|
131
|
+
# github = Github.new oauth_token: '...'
|
|
132
|
+
# github.orgs.members.conceal 'org-name', 'member-name'
|
|
133
|
+
#
|
|
134
|
+
# @api public
|
|
135
|
+
def conceal(*args)
|
|
136
|
+
arguments(args, required: [:org_name, :user])
|
|
137
|
+
|
|
138
|
+
delete_request("/orgs/#{arguments.org_name}/public_members/#{arguments.user}", arguments.params)
|
|
139
|
+
end
|
|
140
|
+
alias_method :conceal_membership, :conceal
|
|
141
|
+
end # Client::Orgs::Members
|
|
142
|
+
end # Github
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Orgs::Memberships < API
|
|
7
|
+
# List your organization memberships
|
|
8
|
+
#
|
|
9
|
+
# @see List your organization memberships
|
|
10
|
+
#
|
|
11
|
+
# @example
|
|
12
|
+
# github = Github.new
|
|
13
|
+
# github.orgs.memberships.list
|
|
14
|
+
#
|
|
15
|
+
# @api public
|
|
16
|
+
def list(*args)
|
|
17
|
+
arguments(args)
|
|
18
|
+
|
|
19
|
+
response = get_request('/user/memberships/orgs', arguments.params)
|
|
20
|
+
return response unless block_given?
|
|
21
|
+
response.each { |el| yield el }
|
|
22
|
+
end
|
|
23
|
+
alias_method :all, :list
|
|
24
|
+
|
|
25
|
+
# Get organization membership
|
|
26
|
+
#
|
|
27
|
+
# In order to get a user's membership with an organization,
|
|
28
|
+
# the authenticated user must be an organization owner.
|
|
29
|
+
#
|
|
30
|
+
# @see https://developer.github.com/v3/orgs/members/#get-organization-membership
|
|
31
|
+
# @param [String] :org
|
|
32
|
+
# @param [String] :username
|
|
33
|
+
#
|
|
34
|
+
# @example
|
|
35
|
+
# github = Github.new oauth_toke: '...'
|
|
36
|
+
# github.orgs.memberships.get 'orgname', username: 'piotr'
|
|
37
|
+
#
|
|
38
|
+
# Get your organization membership
|
|
39
|
+
#
|
|
40
|
+
# @see https://developer.github.com/v3/orgs/members/#get-your-organization-membership
|
|
41
|
+
#
|
|
42
|
+
# @example
|
|
43
|
+
# github = Github.new oauth_token
|
|
44
|
+
# github.orgs.memberships.get 'orgname'
|
|
45
|
+
#
|
|
46
|
+
# @api public
|
|
47
|
+
def get(*args)
|
|
48
|
+
arguments(args, required: [:org_name])
|
|
49
|
+
params = arguments.params
|
|
50
|
+
|
|
51
|
+
if (username = params.delete('username'))
|
|
52
|
+
get_request("/orgs/#{arguments.org_name}/memberships/#{username}", params)
|
|
53
|
+
else
|
|
54
|
+
get_request("/user/memberships/orgs/#{arguments.org_name}", params)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
alias_method :find, :get
|
|
58
|
+
|
|
59
|
+
# Add/update user's membership with organization
|
|
60
|
+
#
|
|
61
|
+
# In order to create or update a user's membership with an organization,
|
|
62
|
+
# the authenticated user must be an organization owner.
|
|
63
|
+
#
|
|
64
|
+
# @see https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership
|
|
65
|
+
#
|
|
66
|
+
# @param [String] :org
|
|
67
|
+
# @param [String] :username
|
|
68
|
+
# @param [Hash] options
|
|
69
|
+
# @option options [String] :role
|
|
70
|
+
# Required. The role to give the user in the organization. Can be one of:
|
|
71
|
+
# * admin - The user will become an owner of the organization.
|
|
72
|
+
# * member - The user will become a non-owner member of the organization.
|
|
73
|
+
#
|
|
74
|
+
# @example
|
|
75
|
+
# github = Github.new oauth_token: '...'
|
|
76
|
+
# github.orgs.memberships.add 'org-name', 'member-name', role: 'role'
|
|
77
|
+
#
|
|
78
|
+
# @api public
|
|
79
|
+
def create(*args)
|
|
80
|
+
arguments(args, required: [:org_name, :username]) do
|
|
81
|
+
assert_required :role
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
put_request("/orgs/#{arguments.org_name}/memberships/#{arguments.username}",
|
|
85
|
+
arguments.params)
|
|
86
|
+
end
|
|
87
|
+
alias_method :update, :create
|
|
88
|
+
alias_method :add, :create
|
|
89
|
+
|
|
90
|
+
# Edit your organization membership
|
|
91
|
+
#
|
|
92
|
+
# @see https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
|
|
93
|
+
# @param [String] :org
|
|
94
|
+
# @param [Hash] params
|
|
95
|
+
# @option params [String] :state
|
|
96
|
+
# Required. The state that the membership should be in.
|
|
97
|
+
# Only "active" will be accepted.
|
|
98
|
+
#
|
|
99
|
+
# @example
|
|
100
|
+
# github = Github.new oauth_token: '...'
|
|
101
|
+
# github.orgs.memberships.edit 'org-name', state: 'active'
|
|
102
|
+
#
|
|
103
|
+
# @api public
|
|
104
|
+
def edit(*args)
|
|
105
|
+
arguments(args, required: [:org_name]) do
|
|
106
|
+
assert_required :state
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
patch_request("/user/memberships/orgs/#{arguments.org_name}",
|
|
110
|
+
arguments.params)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Remove organization membership
|
|
114
|
+
#
|
|
115
|
+
# @see https://developer.github.com/v3/orgs/members/#remove-organization-membership
|
|
116
|
+
# @param [String] :org
|
|
117
|
+
# @param [String] :username
|
|
118
|
+
#
|
|
119
|
+
# @example
|
|
120
|
+
# github = Github.new oauth_token: '...'
|
|
121
|
+
# github.orgs.memberships.remove 'orgname', 'username'
|
|
122
|
+
#
|
|
123
|
+
# @api public
|
|
124
|
+
def delete(*args)
|
|
125
|
+
arguments(args, required: [:org_name, :username])
|
|
126
|
+
|
|
127
|
+
delete_request("/orgs/#{arguments.org_name}/memberships/#{arguments.username}", arguments.params)
|
|
128
|
+
end
|
|
129
|
+
alias_method :remove, :delete
|
|
130
|
+
end # Client::Orgs::Memberships
|
|
131
|
+
end # Github
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Orgs::Projects < API
|
|
7
|
+
PREVIEW_MEDIA = "application/vnd.github.inertia-preview+json".freeze # :nodoc:
|
|
8
|
+
|
|
9
|
+
# List your organization projects
|
|
10
|
+
#
|
|
11
|
+
# @see List your organization projects
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# github = Github.new 'org-name'
|
|
15
|
+
# github.orgs.projects.list 'org-name' { |project| ... }
|
|
16
|
+
#
|
|
17
|
+
# @example
|
|
18
|
+
# github = Github.new
|
|
19
|
+
# github.orgs.projects.list 'org-name', state: 'closed'
|
|
20
|
+
#
|
|
21
|
+
# @api public
|
|
22
|
+
def list(*args)
|
|
23
|
+
arguments(args, required: [:org_name])
|
|
24
|
+
params = arguments.params
|
|
25
|
+
|
|
26
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
27
|
+
|
|
28
|
+
response = get_request("/orgs/#{arguments.org_name}/projects", params)
|
|
29
|
+
return response unless block_given?
|
|
30
|
+
response.each { |el| yield el }
|
|
31
|
+
end
|
|
32
|
+
alias_method :all, :list
|
|
33
|
+
|
|
34
|
+
# Create a new project for the specified repo
|
|
35
|
+
#
|
|
36
|
+
# @param [Hash] params
|
|
37
|
+
# @option params [String] :name
|
|
38
|
+
# Required string - The name of the project.
|
|
39
|
+
# @option params [String] :body
|
|
40
|
+
# Optional string - The body of the project.
|
|
41
|
+
#
|
|
42
|
+
# @example
|
|
43
|
+
# github = Github.new
|
|
44
|
+
# github.repos.create 'owner-name', 'repo-name', name: 'project-name'
|
|
45
|
+
# github.repos.create name: 'project-name', body: 'project-body', owner: 'owner-name', repo: 'repo-name'
|
|
46
|
+
def create(*args)
|
|
47
|
+
arguments(args, required: [:org_name]) do
|
|
48
|
+
assert_required %w[ name ]
|
|
49
|
+
end
|
|
50
|
+
params = arguments.params
|
|
51
|
+
|
|
52
|
+
params["accept"] ||= PREVIEW_MEDIA
|
|
53
|
+
|
|
54
|
+
post_request("/orgs/#{arguments.org_name}/projects", params)
|
|
55
|
+
end
|
|
56
|
+
end # Projects
|
|
57
|
+
end # Github
|