lingfennan-github_api 0.18.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +741 -0
  4. data/lib/github_api.rb +93 -0
  5. data/lib/github_api/api.rb +398 -0
  6. data/lib/github_api/api/actions.rb +60 -0
  7. data/lib/github_api/api/arguments.rb +253 -0
  8. data/lib/github_api/api/config.rb +105 -0
  9. data/lib/github_api/api/config/property.rb +30 -0
  10. data/lib/github_api/api/config/property_set.rb +120 -0
  11. data/lib/github_api/api/factory.rb +33 -0
  12. data/lib/github_api/authorization.rb +75 -0
  13. data/lib/github_api/client.rb +77 -0
  14. data/lib/github_api/client/activity.rb +31 -0
  15. data/lib/github_api/client/activity/events.rb +233 -0
  16. data/lib/github_api/client/activity/feeds.rb +50 -0
  17. data/lib/github_api/client/activity/notifications.rb +181 -0
  18. data/lib/github_api/client/activity/starring.rb +130 -0
  19. data/lib/github_api/client/activity/watching.rb +176 -0
  20. data/lib/github_api/client/authorizations.rb +142 -0
  21. data/lib/github_api/client/authorizations/app.rb +98 -0
  22. data/lib/github_api/client/emojis.rb +19 -0
  23. data/lib/github_api/client/gists.rb +289 -0
  24. data/lib/github_api/client/gists/comments.rb +100 -0
  25. data/lib/github_api/client/git_data.rb +31 -0
  26. data/lib/github_api/client/git_data/blobs.rb +51 -0
  27. data/lib/github_api/client/git_data/commits.rb +101 -0
  28. data/lib/github_api/client/git_data/references.rb +150 -0
  29. data/lib/github_api/client/git_data/tags.rb +95 -0
  30. data/lib/github_api/client/git_data/trees.rb +113 -0
  31. data/lib/github_api/client/gitignore.rb +57 -0
  32. data/lib/github_api/client/issues.rb +248 -0
  33. data/lib/github_api/client/issues/assignees.rb +77 -0
  34. data/lib/github_api/client/issues/comments.rb +146 -0
  35. data/lib/github_api/client/issues/events.rb +50 -0
  36. data/lib/github_api/client/issues/labels.rb +189 -0
  37. data/lib/github_api/client/issues/milestones.rb +146 -0
  38. data/lib/github_api/client/markdown.rb +62 -0
  39. data/lib/github_api/client/meta.rb +19 -0
  40. data/lib/github_api/client/orgs.rb +127 -0
  41. data/lib/github_api/client/orgs/hooks.rb +182 -0
  42. data/lib/github_api/client/orgs/members.rb +142 -0
  43. data/lib/github_api/client/orgs/memberships.rb +131 -0
  44. data/lib/github_api/client/orgs/projects.rb +57 -0
  45. data/lib/github_api/client/orgs/teams.rb +407 -0
  46. data/lib/github_api/client/projects.rb +83 -0
  47. data/lib/github_api/client/projects/cards.rb +158 -0
  48. data/lib/github_api/client/projects/columns.rb +146 -0
  49. data/lib/github_api/client/pull_requests.rb +195 -0
  50. data/lib/github_api/client/pull_requests/comments.rb +140 -0
  51. data/lib/github_api/client/pull_requests/reviews.rb +158 -0
  52. data/lib/github_api/client/repos.rb +468 -0
  53. data/lib/github_api/client/repos/branches.rb +48 -0
  54. data/lib/github_api/client/repos/branches/protections.rb +75 -0
  55. data/lib/github_api/client/repos/collaborators.rb +84 -0
  56. data/lib/github_api/client/repos/comments.rb +125 -0
  57. data/lib/github_api/client/repos/commits.rb +80 -0
  58. data/lib/github_api/client/repos/contents.rb +246 -0
  59. data/lib/github_api/client/repos/deployments.rb +138 -0
  60. data/lib/github_api/client/repos/downloads.rb +62 -0
  61. data/lib/github_api/client/repos/forks.rb +48 -0
  62. data/lib/github_api/client/repos/hooks.rb +214 -0
  63. data/lib/github_api/client/repos/keys.rb +104 -0
  64. data/lib/github_api/client/repos/merging.rb +47 -0
  65. data/lib/github_api/client/repos/pages.rb +48 -0
  66. data/lib/github_api/client/repos/projects.rb +62 -0
  67. data/lib/github_api/client/repos/pub_sub_hubbub.rb +133 -0
  68. data/lib/github_api/client/repos/releases.rb +189 -0
  69. data/lib/github_api/client/repos/releases/assets.rb +136 -0
  70. data/lib/github_api/client/repos/releases/tags.rb +24 -0
  71. data/lib/github_api/client/repos/statistics.rb +89 -0
  72. data/lib/github_api/client/repos/statuses.rb +91 -0
  73. data/lib/github_api/client/say.rb +25 -0
  74. data/lib/github_api/client/scopes.rb +46 -0
  75. data/lib/github_api/client/search.rb +133 -0
  76. data/lib/github_api/client/search/legacy.rb +111 -0
  77. data/lib/github_api/client/users.rb +117 -0
  78. data/lib/github_api/client/users/emails.rb +65 -0
  79. data/lib/github_api/client/users/followers.rb +115 -0
  80. data/lib/github_api/client/users/keys.rb +104 -0
  81. data/lib/github_api/configuration.rb +70 -0
  82. data/lib/github_api/connection.rb +82 -0
  83. data/lib/github_api/constants.rb +61 -0
  84. data/lib/github_api/core_ext/array.rb +25 -0
  85. data/lib/github_api/core_ext/hash.rb +91 -0
  86. data/lib/github_api/core_ext/ordered_hash.rb +107 -0
  87. data/lib/github_api/deprecation.rb +39 -0
  88. data/lib/github_api/error.rb +32 -0
  89. data/lib/github_api/error/client_error.rb +89 -0
  90. data/lib/github_api/error/service_error.rb +223 -0
  91. data/lib/github_api/ext/faraday.rb +38 -0
  92. data/lib/github_api/mash.rb +7 -0
  93. data/lib/github_api/middleware.rb +37 -0
  94. data/lib/github_api/mime_type.rb +33 -0
  95. data/lib/github_api/normalizer.rb +23 -0
  96. data/lib/github_api/null_encoder.rb +25 -0
  97. data/lib/github_api/page_iterator.rb +138 -0
  98. data/lib/github_api/page_links.rb +63 -0
  99. data/lib/github_api/paged_request.rb +42 -0
  100. data/lib/github_api/pagination.rb +115 -0
  101. data/lib/github_api/parameter_filter.rb +35 -0
  102. data/lib/github_api/params_hash.rb +115 -0
  103. data/lib/github_api/rate_limit.rb +25 -0
  104. data/lib/github_api/request.rb +85 -0
  105. data/lib/github_api/request/basic_auth.rb +36 -0
  106. data/lib/github_api/request/jsonize.rb +54 -0
  107. data/lib/github_api/request/oauth2.rb +44 -0
  108. data/lib/github_api/request/verbs.rb +63 -0
  109. data/lib/github_api/response.rb +48 -0
  110. data/lib/github_api/response/atom_parser.rb +22 -0
  111. data/lib/github_api/response/follow_redirects.rb +140 -0
  112. data/lib/github_api/response/header.rb +87 -0
  113. data/lib/github_api/response/jsonize.rb +28 -0
  114. data/lib/github_api/response/mashify.rb +24 -0
  115. data/lib/github_api/response/raise_error.rb +22 -0
  116. data/lib/github_api/response/xmlize.rb +27 -0
  117. data/lib/github_api/response_wrapper.rb +161 -0
  118. data/lib/github_api/ssl_certs/cacerts.pem +2183 -0
  119. data/lib/github_api/utils/url.rb +63 -0
  120. data/lib/github_api/validations.rb +22 -0
  121. data/lib/github_api/validations/format.rb +26 -0
  122. data/lib/github_api/validations/presence.rb +32 -0
  123. data/lib/github_api/validations/required.rb +21 -0
  124. data/lib/github_api/validations/token.rb +41 -0
  125. data/lib/github_api/version.rb +5 -0
  126. metadata +338 -0
@@ -0,0 +1,146 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Issues::Comments < API
7
+
8
+ VALID_ISSUE_COMMENT_PARAM_NAME = %w[
9
+ body
10
+ resource
11
+ mime_type
12
+ ].freeze
13
+
14
+ # List comments on an issue
15
+ #
16
+ # @example
17
+ # github = Github.new
18
+ # github.issues.comments.all 'owner-name', 'repo-name', number: 'id'
19
+ # github.issues.comments.all 'owner-name', 'repo-name', number: 'id' {|com| .. }
20
+ # @example
21
+ # github.issues.comments.all owner: 'username', repo: 'repo-name', number: 'id'
22
+ #
23
+ # List comments in a repository
24
+ #
25
+ # @param [Hash] params
26
+ # @option params [String] :sort
27
+ # Optional string, created or updated
28
+ # @option params [String] :direction
29
+ # Optional string, asc or desc. Ignored with sort parameter.
30
+ # @option params [String] :since
31
+ # Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
32
+ #
33
+ # @example
34
+ # github = Github.new
35
+ # github.issues.comments.all 'user-name', 'repo-name'
36
+ # github.issues.comments.all 'user-name', 'repo-name' {|com| .. }
37
+ #
38
+ # @api public
39
+ def list(*args)
40
+ arguments(args, required: [:user, :repo])
41
+ params = arguments.params
42
+
43
+ response = if (number = params.delete('number'))
44
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{number}/comments", params)
45
+ else
46
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/comments", params)
47
+ end
48
+ return response unless block_given?
49
+ response.each { |el| yield el }
50
+ end
51
+ alias :all :list
52
+
53
+ # Get a single comment
54
+ #
55
+ # @example
56
+ # github = Github.new
57
+ # github.issues.comments.find 'user-name', 'repo-name', 'id'
58
+ #
59
+ # @example
60
+ # github.issues.comments.find owner: 'user-name', repo: 'repo-name', id: 'id'
61
+ #
62
+ def get(*args)
63
+ arguments(args, required: [:user, :repo, :id])
64
+ params = arguments.params
65
+
66
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/comments/#{arguments.id}", params)
67
+ end
68
+ alias :find :get
69
+
70
+ # Create a comment
71
+ #
72
+ # @param [Hash] params
73
+ # @option [String] :body
74
+ # Required string
75
+ #
76
+ # @example
77
+ # github = Github.new
78
+ # github.issues.comments.create 'user-name', 'repo-name', 'number',
79
+ # body: 'a new comment'
80
+ #
81
+ # @example
82
+ # github.issues.comments.create
83
+ # user: 'owner-name',
84
+ # repo: 'repo-name',
85
+ # number: 'issue-number',
86
+ # body: 'a new comment body'
87
+ #
88
+ # @api public
89
+ def create(*args)
90
+ arguments(args, required: [:user, :repo, :number]) do
91
+ permit VALID_ISSUE_COMMENT_PARAM_NAME
92
+ assert_required %w[ body ]
93
+ end
94
+ params = arguments.params
95
+
96
+ post_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/comments", params)
97
+ end
98
+
99
+ # Edit a comment
100
+ #
101
+ # @param [Hash] params
102
+ # @option params [String] :body
103
+ # Required string
104
+ #
105
+ # @example
106
+ # github = Github.new
107
+ # github.issues.comments.edit 'owner-name', 'repo-name', 'id',
108
+ # body: 'a new comment'
109
+ #
110
+ # @example
111
+ # github.issues.comments.edit
112
+ # user: 'owner-name',
113
+ # repo: 'repo-name',
114
+ # id: 'comment-id',
115
+ # body: 'a new comment body'
116
+ #
117
+ # @api public
118
+ def edit(*args)
119
+ arguments(args, required: [:user, :repo, :id]) do
120
+ permit VALID_ISSUE_COMMENT_PARAM_NAME
121
+ assert_required %w[ body ]
122
+ end
123
+
124
+ patch_request("/repos/#{arguments.user}/#{arguments.repo}/issues/comments/#{arguments.id}", arguments.params)
125
+ end
126
+
127
+ # Delete a comment
128
+ #
129
+ # = Examples
130
+ # github = Github.new
131
+ # github.issues.comments.delete 'owner-name', 'repo-name', 'comment-id'
132
+ #
133
+ # @example
134
+ # github.issues.comments.delete
135
+ # user: 'owner-name',
136
+ # repo: 'repo-name',
137
+ # id: 'comment-id',
138
+ #
139
+ # @api public
140
+ def delete(*args)
141
+ arguments(args, required: [:user, :repo, :id])
142
+
143
+ delete_request("/repos/#{arguments.user}/#{arguments.repo}/issues/comments/#{arguments.id}", arguments.params)
144
+ end
145
+ end # Issues::Comments
146
+ end # Github
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Issues::Events < API
7
+ # List events for an issue
8
+ #
9
+ # @example
10
+ # github = Github.new
11
+ # github.issues.events.list 'user-name', 'repo-name',
12
+ # issue_number: 'issue-number'
13
+ #
14
+ # List events for a repository
15
+ #
16
+ # @example
17
+ # github = Github.new
18
+ # github.issues.events.list 'user-name', 'repo-name'
19
+ #
20
+ # @api public
21
+ def list(*args)
22
+ arguments(args, required: [:user, :repo])
23
+ params = arguments.params
24
+
25
+ response = if (issue_number = params.delete('issue_number'))
26
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{issue_number}/events", params)
27
+ else
28
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/events", params)
29
+ end
30
+ return response unless block_given?
31
+ response.each { |el| yield el }
32
+ end
33
+ alias :all :list
34
+
35
+ # Get a single event
36
+ #
37
+ # @example
38
+ # github = Github.new
39
+ # github.issues.events.get 'user-name', 'repo-name', 'event-id'
40
+ #
41
+ # @api public
42
+ def get(*args)
43
+ arguments(args, :required => [:user, :repo, :id])
44
+ params = arguments.params
45
+
46
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/events/#{arguments.id}", params)
47
+ end
48
+ alias :find :get
49
+ end # Issues::Events
50
+ end # Github
@@ -0,0 +1,189 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Issues::Labels < API
7
+
8
+ VALID_LABEL_INPUTS = %w[ name color ].freeze
9
+
10
+ # List all labels for a repository
11
+ #
12
+ # @example
13
+ # github = Github.new user: 'user-name', repo: 'repo-name'
14
+ # github.issues.labels.list
15
+ # github.issues.labels.list { |label| ... }
16
+ #
17
+ # Get labels for every issue in a milestone
18
+ #
19
+ # @example
20
+ # github = Github.new
21
+ # github.issues.labels.list 'user-name', 'repo-name', milestone_id: 'milestone-id'
22
+ #
23
+ # List labels on an issue
24
+ #
25
+ # @example
26
+ # github = Github.new
27
+ # github.issues.labels.list 'user-name', 'repo-name', issue_id: 'issue-id'
28
+ #
29
+ # @api public
30
+ def list(*args)
31
+ arguments(args, required: [:user, :repo])
32
+ params = arguments.params
33
+ user = arguments.user
34
+ repo = arguments.repo
35
+
36
+ response = if (milestone_id = params.delete('milestone_id'))
37
+ get_request("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels", params)
38
+ elsif (issue_id = params.delete('issue_id'))
39
+ get_request("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
40
+ else
41
+ get_request("/repos/#{user}/#{repo}/labels", params)
42
+ end
43
+ return response unless block_given?
44
+ response.each { |el| yield el }
45
+ end
46
+ alias :all :list
47
+
48
+ # Get a single label
49
+ #
50
+ # @example
51
+ # github = Github.new
52
+ # github.issues.labels.find 'user-name', 'repo-name', 'label-name'
53
+ #
54
+ # @example
55
+ # github = Github.new user: 'user-name', repo: 'repo-name'
56
+ # github.issues.labels.get label_name: 'bug'
57
+ #
58
+ # @api public
59
+ def get(*args)
60
+ arguments(args, required: [:user, :repo, :label_name])
61
+ params = arguments.params
62
+
63
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", params)
64
+ end
65
+ alias :find :get
66
+
67
+ # Create a label
68
+ #
69
+ # @param [Hash] params
70
+ # @option params [String] :name
71
+ # Required string
72
+ # @option params [String] :color
73
+ # Required string - 6 character hex code, without leading #
74
+ #
75
+ # @example
76
+ # github = Github.new user: 'user-name', repo: 'repo-name'
77
+ # github.issues.labels.create name: 'API', color: 'FFFFFF'
78
+ #
79
+ # @api public
80
+ def create(*args)
81
+ arguments(args, required: [:user, :repo]) do
82
+ permit VALID_LABEL_INPUTS
83
+ assert_required VALID_LABEL_INPUTS
84
+ end
85
+
86
+ post_request("/repos/#{arguments.user}/#{arguments.repo}/labels", arguments.params)
87
+ end
88
+
89
+ # Update a label
90
+ #
91
+ # @param [Hash] params
92
+ # @option params [String] :name
93
+ # Required string
94
+ # @option params [String] :color
95
+ # Required string - 6 character hex code, without leading #
96
+ #
97
+ # @example
98
+ # github = Github.new
99
+ # github.issues.labels.update 'user-name', 'repo-name', 'label-name',
100
+ # name: 'API', color: "FFFFFF"
101
+ #
102
+ # @api public
103
+ def update(*args)
104
+ arguments(args, required: [:user, :repo, :label_name]) do
105
+ permit VALID_LABEL_INPUTS
106
+ assert_required VALID_LABEL_INPUTS
107
+ end
108
+
109
+ patch_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", arguments.params)
110
+ end
111
+ alias :edit :update
112
+
113
+ # Delete a label
114
+ #
115
+ # @examples
116
+ # github = Github.new
117
+ # github.issues.labels.delete 'user-name', 'repo-name', 'label-name'
118
+ #
119
+ # @api public
120
+ def delete(*args)
121
+ arguments(args, required: [:user, :repo, :label_name])
122
+
123
+ delete_request("/repos/#{arguments.user}/#{arguments.repo}/labels/#{arguments.label_name}", arguments.params)
124
+ end
125
+
126
+ # Add labels to an issue
127
+ #
128
+ # @example
129
+ # github = Github.new
130
+ # github.issues.labels.add 'user-name', 'repo-name', 'issue-number',
131
+ # 'label1', 'label2', ...
132
+ #
133
+ # @api public
134
+ def add(*args)
135
+ arguments(args, required: [:user, :repo, :number])
136
+ params = arguments.params
137
+ params['data'] = arguments.remaining unless arguments.remaining.empty?
138
+
139
+ post_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/labels", params)
140
+ end
141
+ alias :<< :add
142
+
143
+ # Remove a label from an issue
144
+ #
145
+ # @example
146
+ # github = Github.new
147
+ # github.issues.labels.remove 'user-name', 'repo-name', 'issue-number',
148
+ # label_name: 'label-name'
149
+ #
150
+ # Remove all labels from an issue
151
+ #
152
+ # @example
153
+ # github = Github.new
154
+ # github.issues.labels.remove 'user-name', 'repo-name', 'issue-number'
155
+ #
156
+ # @api public
157
+ def remove(*args)
158
+ arguments(args, required: [:user, :repo, :number])
159
+ params = arguments.params
160
+ user = arguments.user
161
+ repo = arguments.repo
162
+ number = arguments.number
163
+
164
+ if (label_name = params.delete('label_name'))
165
+ delete_request("/repos/#{user}/#{repo}/issues/#{number}/labels/#{label_name}", params)
166
+ else
167
+ delete_request("/repos/#{user}/#{repo}/issues/#{number}/labels", params)
168
+ end
169
+ end
170
+
171
+ # Replace all labels for an issue
172
+ #
173
+ # Sending an empty array ([]) will remove all Labels from the Issue.
174
+ #
175
+ # @example
176
+ # github = Github.new
177
+ # github.issues.labels.replace 'user-name', 'repo-name', 'issue-number',
178
+ # 'label1', 'label2', ...
179
+ #
180
+ # @api public
181
+ def replace(*args)
182
+ arguments(args, required: [:user, :repo, :number])
183
+ params = arguments.params
184
+ params['data'] = arguments.remaining unless arguments.remaining.empty?
185
+
186
+ put_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/labels", params)
187
+ end
188
+ end # Issues::Labels
189
+ end # Github
@@ -0,0 +1,146 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../../api'
4
+
5
+ module Github
6
+ class Client::Issues::Milestones < API
7
+
8
+ VALID_MILESTONE_OPTIONS = {
9
+ 'state' => %w[ open closed all ],
10
+ 'sort' => %w[ due_date completeness ],
11
+ 'direction' => %w[ desc asc ]
12
+ }.freeze # :nodoc:
13
+
14
+ VALID_MILESTONE_INPUTS = %w[
15
+ title
16
+ state
17
+ description
18
+ due_on
19
+ ].freeze # :nodoc:
20
+
21
+ # List milestones for a repository
22
+ #
23
+ # @param [Hash] params
24
+ # @option params [String] :state
25
+ # The state of the milestone. Either open, closed, or all. Default: open
26
+ # @option params [String] :sort
27
+ # What to sort results by. Either due_date or completeness.
28
+ # Default: due_date
29
+ # @option params [String] :direction
30
+ # The directoin of the sort. Either asc or desc. Default: desc
31
+ #
32
+ # @example
33
+ # github = Github.new user: 'user-name', repo: 'repo-name'
34
+ # github.issues.milestones.list
35
+ #
36
+ # @example
37
+ # github.issues.milestones.list state: 'open', sort: 'due_date',
38
+ # direction: 'asc'
39
+ #
40
+ # @api public
41
+ def list(*args)
42
+ arguments(args, required: [:user, :repo]) do
43
+ permit VALID_MILESTONE_OPTIONS.keys
44
+ assert_values VALID_MILESTONE_OPTIONS
45
+ end
46
+
47
+ response = get_request("/repos/#{arguments.user}/#{arguments.repo}/milestones", arguments.params)
48
+ return response unless block_given?
49
+ response.each { |el| yield el }
50
+ end
51
+ alias :all :list
52
+
53
+ # Get a single milestone
54
+ #
55
+ # @example
56
+ # github = Github.new
57
+ # github.issues.milestones.get 'user-name', 'repo-name', 'milestone-number'
58
+ #
59
+ # @example
60
+ # github.issues.milestones.get
61
+ # user: 'user-name',
62
+ # repo: 'repo-name',
63
+ # number: 'milestone-number'
64
+ #
65
+ # @api public
66
+ def get(*args)
67
+ arguments(args, required: [:user, :repo, :number])
68
+
69
+ get_request("/repos/#{arguments.user}/#{arguments.repo}/milestones/#{arguments.number}", arguments.params)
70
+ end
71
+ alias :find :get
72
+
73
+ # Create a milestone
74
+ #
75
+ # @param [Hash] params
76
+ # @option params [String] :title
77
+ # Required string. The title of the milestone
78
+ # @option params [String] :state
79
+ # The state of the milestone. Either open or closed. Default: open.
80
+ # @option params [String] :description
81
+ # A description of the milestone
82
+ # @option params [String] :due_on
83
+ # The milestone due date. This is a timestamp in ISO 8601 format:
84
+ # YYYY-MM-DDTHH:MM:SSZ.
85
+ #
86
+ # @example
87
+ # github = Github.new user: 'user-name', repo: 'repo-name'
88
+ # github.issues.milestones.create title: 'hello-world',
89
+ # state: "open or closed",
90
+ # description: "String",
91
+ # due_on: "Time"
92
+ #
93
+ # @api public
94
+ def create(*args)
95
+ arguments(args, required: [:user, :repo]) do
96
+ permit VALID_MILESTONE_INPUTS
97
+ assert_required %w[ title ]
98
+ end
99
+
100
+ post_request("/repos/#{arguments.user}/#{arguments.repo}/milestones", arguments.params)
101
+ end
102
+
103
+ # Update a milestone
104
+ #
105
+ # @param [Hash] params
106
+ # @option params [String] :title
107
+ # Required string. The title of the milestone
108
+ # @option params [String] :state
109
+ # The state of the milestone. Either open or closed. Default: open.
110
+ # @option params [String] :description
111
+ # A description of the milestone
112
+ # @option params [String] :due_on
113
+ # The milestone due date. This is a timestamp in ISO 8601 format:
114
+ # YYYY-MM-DDTHH:MM:SSZ.
115
+ #
116
+ # @example
117
+ # github = Github.new
118
+ # github.issues.milestones.update 'user-name', 'repo-name', 'number',
119
+ # :title => 'hello-world',
120
+ # :state => "open or closed",
121
+ # :description => "String",
122
+ # :due_on => "Time"
123
+ #
124
+ # @api public
125
+ def update(*args)
126
+ arguments(args, required: [:user, :repo, :number]) do
127
+ permit VALID_MILESTONE_INPUTS
128
+ end
129
+
130
+ patch_request("/repos/#{arguments.user}/#{arguments.repo}/milestones/#{arguments.number}", arguments.params)
131
+ end
132
+
133
+ # Delete a milestone
134
+ #
135
+ # @example
136
+ # github = Github.new
137
+ # github.issues.milestones.delete 'user-name', 'repo-name', 'number'
138
+ #
139
+ # @api public
140
+ def delete(*args)
141
+ arguments(args, required: [:user, :repo, :number])
142
+
143
+ delete_request("/repos/#{arguments.user}/#{arguments.repo}/milestones/#{arguments.number}", arguments.params)
144
+ end
145
+ end # Issues::Milestones
146
+ end # Github