octokit 4.0.1 → 4.1.0

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
  SHA1:
3
- metadata.gz: db13043bdffc8bb386b79815c7fcaa147f70119a
4
- data.tar.gz: a41b685e73c8c4b0e9034f2bab9f73ced1a9240a
3
+ metadata.gz: 42f87b8ae5be0908f5ebf3ea440b326dfeb90a67
4
+ data.tar.gz: c81981cf6ef79e3e12a1af37100ce931b3a5ecbe
5
5
  SHA512:
6
- metadata.gz: b0db38b08765e340731f8707ca33df7ee8f4da773618f95fadde065bc12fe1bd5d9f30cd8be7a3001e6c4cef03ead63e572f5ef8cb6ca53416214ff877e9182f
7
- data.tar.gz: a6cebf076f7faf4ae57e79bf3f3ef833dbdb3280a86df6d3af90d5fb877c0e8dd13a8fdab9da387db3fdcd2d931fbdfc4f4d988e118eb0c825a98370e87286ef
6
+ metadata.gz: 3b0c8b13dcad559baeaed2e3ffd5eeba73755baaeca30cc0b36514d9050fc3a6f7f6d8638465cb7b1e0bc3c6807c08cba6760eb3ff0bb8453781557ab9d7b42a
7
+ data.tar.gz: 4d3967580680dddd45f89fd64c327512ce90f64829070c82070e9dae2109308772f1879b8b5ea1c952b10b63313656b3d9a625aa156b7fec7c6c41354b1ab903
data/README.md CHANGED
@@ -33,7 +33,7 @@ Install via Rubygems
33
33
 
34
34
  ... or add to your Gemfile
35
35
 
36
- gem "octokit", "~> 3.0"
36
+ gem "octokit", "~> 4.0"
37
37
 
38
38
  ### Making requests
39
39
 
@@ -9,6 +9,7 @@ require 'octokit/rate_limit'
9
9
  require 'octokit/repository'
10
10
  require 'octokit/user'
11
11
  require 'octokit/organization'
12
+ require 'octokit/preview'
12
13
  require 'octokit/client/authorizations'
13
14
  require 'octokit/client/commits'
14
15
  require 'octokit/client/commit_comments'
@@ -55,6 +56,7 @@ module Octokit
55
56
  include Octokit::Authentication
56
57
  include Octokit::Configurable
57
58
  include Octokit::Connection
59
+ include Octokit::Preview
58
60
  include Octokit::Warnable
59
61
  include Octokit::Client::Authorizations
60
62
  include Octokit::Client::Commits
@@ -188,5 +190,23 @@ module Octokit
188
190
  reset_agent
189
191
  @client_secret = value
190
192
  end
193
+
194
+ def client_without_redirects(options = {})
195
+ conn_opts = @connection_options
196
+ conn_opts[:url] = @api_endpoint
197
+ conn_opts[:builder] = @middleware.dup if @middleware
198
+ conn_opts[:proxy] = @proxy if @proxy
199
+ conn = Faraday.new(conn_opts) do |http|
200
+ if basic_authenticated?
201
+ http.basic_auth(@login, @password)
202
+ elsif token_authenticated?
203
+ http.authorization 'token', @access_token
204
+ end
205
+ http.headers['accept'] = options[:accept] if options.key?(:accept)
206
+ end
207
+ conn.builder.delete(Octokit::Middleware::FollowRedirects)
208
+
209
+ conn
210
+ end
191
211
  end
192
212
  end
@@ -154,20 +154,7 @@ module Octokit
154
154
  format = (options.delete :format) || 'tarball'
155
155
  url = "#{Repository.path repo}/#{format}/#{repo_ref}"
156
156
 
157
- conn_opts = @connection_options
158
- conn_opts[:url] = @api_endpoint
159
- conn_opts[:builder] = @middleware.dup if @middleware
160
- conn_opts[:proxy] = @proxy if @proxy
161
- conn = Faraday.new(conn_opts) do |http|
162
- if basic_authenticated?
163
- http.basic_auth(@login, @password)
164
- elsif token_authenticated?
165
- http.authorization 'token', @access_token
166
- end
167
- end
168
- conn.builder.delete(Octokit::Middleware::FollowRedirects)
169
- response = conn.head(url, options)
170
-
157
+ response = client_without_redirects.head(url, options)
171
158
  response.headers['Location']
172
159
  end
173
160
  end
@@ -11,7 +11,7 @@ module Octokit
11
11
  # @param repository [Integer, String, Repository, Hash] A GitHub repository.
12
12
  # @param options [Sawyer::Resource] A customizable set of options.
13
13
  # @option options [Integer] :milestone Milestone number.
14
- # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
14
+ # @option options [String] :state (open) State: <tt>open</tt>, <tt>closed</tt>, or <tt>all</tt>.
15
15
  # @option options [String] :assignee User login.
16
16
  # @option options [String] :creator User login.
17
17
  # @option options [String] :mentioned User login.
@@ -37,7 +37,7 @@ module Octokit
37
37
  #
38
38
  # @param options [Sawyer::Resource] A customizable set of options.
39
39
  # @option options [String] :filter (assigned) State: <tt>assigned</tt>, <tt>created</tt>, <tt>mentioned</tt>, <tt>subscribed</tt> or <tt>closed</tt>.
40
- # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
40
+ # @option options [String] :state (open) State: <tt>open</tt>, <tt>closed</tt>, or <tt>all</tt>.
41
41
  # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
42
42
  # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
43
43
  # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
@@ -58,7 +58,7 @@ module Octokit
58
58
  # @param org [String, Integer] Organization GitHub login or id.
59
59
  # @param options [Sawyer::Resource] A customizable set of options.
60
60
  # @option options [String] :filter (assigned) State: <tt>assigned</tt>, <tt>created</tt>, <tt>mentioned</tt>, <tt>subscribed</tt> or <tt>closed</tt>.
61
- # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
61
+ # @option options [String] :state (open) State: <tt>open</tt>, <tt>closed</tt>, or <tt>all</tt>.
62
62
  # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
63
63
  # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
64
64
  # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
@@ -5,8 +5,6 @@ module Octokit
5
5
  #
6
6
  module Licenses
7
7
 
8
- LICENSES_PREVIEW_MEDIA_TYPE = "application/vnd.github.drax-preview+json".freeze
9
-
10
8
  # List all licenses
11
9
  #
12
10
  # @see https://developer.github.com/v3/licenses/#list-all-licenses
@@ -14,7 +12,7 @@ module Octokit
14
12
  # @example
15
13
  # Octokit.licenses
16
14
  def licenses(options = {})
17
- options = ensure_license_api_media_type(options)
15
+ options = ensure_api_media_type(:licenses, options)
18
16
  paginate "licenses", options
19
17
  end
20
18
 
@@ -26,25 +24,9 @@ module Octokit
26
24
  # @example
27
25
  # Octokit.license 'mit'
28
26
  def license(license_name, options = {})
29
- options = ensure_license_api_media_type(options)
27
+ options = ensure_api_media_type(:licenses, options)
30
28
  get "licenses/#{license_name}", options
31
29
  end
32
-
33
- def ensure_license_api_media_type(options = {})
34
- if options[:accept].nil?
35
- options[:accept] = LICENSES_PREVIEW_MEDIA_TYPE
36
- warn_license_preview
37
- end
38
- options
39
- end
40
-
41
- def warn_license_preview
42
- warn <<-EOS
43
- WARNING: The preview version of the License API is not yet suitable for production use.
44
- You can avoid this message by supplying an appropriate media type in the 'Accept' request
45
- header.
46
- EOS
47
- end
48
30
  end
49
31
  end
50
32
  end
@@ -11,7 +11,7 @@ module Octokit
11
11
  # @param repository [String, Repository, Hash] A GitHub repository.
12
12
  # @param options [Hash] A customizable set of options.
13
13
  # @option options [Integer] :milestone Milestone number.
14
- # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
14
+ # @option options [String] :state (open) State: <tt>open</tt>, <tt>closed</tt>, or <tt>all</tt>.
15
15
  # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
16
16
  # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
17
17
  # @return [Array<Sawyer::Resource>] A list of milestones for a repository.
@@ -28,9 +28,6 @@ module Octokit
28
28
  # @param repository [String, Repository, Hash] A GitHub repository.
29
29
  # @param options [Hash] A customizable set of options.
30
30
  # @option options [Integer] :milestone Milestone number.
31
- # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
32
- # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
33
- # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
34
31
  # @return [Sawyer::Resource] A single milestone from a repository.
35
32
  # @see https://developer.github.com/v3/issues/milestones/#get-a-single-milestone
36
33
  # @example Get a single milestone for a repository
@@ -595,6 +595,87 @@ module Octokit
595
595
  user = options.delete(:user)
596
596
  user && boolean_from_response(:delete, "orgs/#{org}/memberships/#{user}", options)
597
597
  end
598
+
599
+ # Initiates the generation of a migration archive.
600
+ #
601
+ # Requires authenticated organization owner.
602
+ #
603
+ # @param org [String, Integer] Organization GitHub login or id.
604
+ # @param repositories [Array<String>] :repositories Repositories for the organization.
605
+ # @option options [Boolean, optional] :lock_repositories Indicates whether repositories should be locked during migration
606
+ # @return [Sawyer::Resource] Hash representing the new migration.
607
+ # @see https://developer.github.com/v3/orgs/teams/#create-team
608
+ # @example
609
+ # @client.start_migration('github', ['github/dotfiles'])
610
+ # @see https://developer.github.com/v3/orgs/migrations/#start-a-migration
611
+ def start_migration(org, repositories, options = {})
612
+ options = ensure_api_media_type(:migrations, options)
613
+ post "orgs/#{org}/migrations", options
614
+ end
615
+
616
+ # Lists the most recent migrations.
617
+ #
618
+ # Requires authenticated organization owner.
619
+ #
620
+ # @param org [String, Integer] Organization GitHub login or id.
621
+ # @return [Array<Sawyer::Resource>] Array of migration resources.
622
+ # @see https://developer.github.com/v3/orgs/migrations/#get-a-list-of-migrations
623
+ def migrations(org, options = {})
624
+ options = ensure_api_media_type(:migrations, options)
625
+ paginate "orgs/#{org}/migrations", options
626
+ end
627
+
628
+ # Fetches the status of a migration.
629
+ #
630
+ # Requires authenticated organization owner.
631
+ #
632
+ # @param org [String, Integer] Organization GitHub login or id.
633
+ # @param id [Integer] ID number of the migration.
634
+ # @see https://developer.github.com/v3/orgs/migrations/#get-a-list-of-migrations
635
+ def migration_status(org, id, options = {})
636
+ options = ensure_api_media_type(:migrations, options)
637
+ get "orgs/#{org}/migrations/#{id}", options
638
+ end
639
+
640
+ # Fetches the URL to a migration archive.
641
+ #
642
+ # Requires authenticated organization owner.
643
+ #
644
+ # @param org [String, Integer] Organization GitHub login or id.
645
+ # @param id [Integer] ID number of the migration.
646
+ # @see https://developer.github.com/v3/orgs/migrations/#download-a-migration-archive
647
+ def migration_archive_url(org, id, options = {})
648
+ options = ensure_api_media_type(:migrations, options)
649
+ url = "orgs/#{org}/migrations/#{id}/archive"
650
+
651
+ response = client_without_redirects(options).get(url)
652
+ response.headers['location']
653
+ end
654
+
655
+ # Deletes a previous migration archive.
656
+ #
657
+ # Requires authenticated organization owner.
658
+ #
659
+ # @param org [String, Integer] Organization GitHub login or id.
660
+ # @param id [Integer] ID number of the migration.
661
+ # @see https://developer.github.com/v3/orgs/migrations/#get-a-list-of-migrations
662
+ def delete_migration_archive(org, id, options = {})
663
+ options = ensure_api_media_type(:migrations, options)
664
+ delete "orgs/#{org}/migrations/#{id}/archive", options
665
+ end
666
+
667
+ # Unlock a previous migration archive.
668
+ #
669
+ # Requires authenticated organization owner.
670
+ #
671
+ # @param org [String, Integer] Organization GitHub login or id.
672
+ # @param id [Integer] ID number of the migration.
673
+ # @param repo [String] Name of the repository.
674
+ # @see https://developer.github.com/v3/orgs/migrations/#unlock-a-repository
675
+ def unlock_repository(org, id, repo, options = {})
676
+ options = ensure_api_media_type(:migrations, options)
677
+ delete "orgs/#{org}/migrations/#{id}/repos/#{repo}/lock", options
678
+ end
598
679
  end
599
680
  end
600
681
  end
@@ -23,7 +23,7 @@ module Octokit
23
23
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
24
24
  # @return [Array<Sawyer::Resource>] The last year of commit activity grouped by
25
25
  # week. The days array is a group of commits per day, starting on Sunday.
26
- # @see https://developer.github.com/v3/repos/statistics/#get-the-last-year-of-commit-activity-data
26
+ # @see https://developer.github.com/v3/repos/statistics/#commit-activity
27
27
  # @example Get commit activity for octokit
28
28
  # @client.commit_activity_stats('octokit/octokit.rb')
29
29
  def commit_activity_stats(repo, options = {})
@@ -3,6 +3,7 @@ require 'octokit/configurable'
3
3
  require 'octokit/warnable'
4
4
  require 'octokit/enterprise_admin_client/admin_stats'
5
5
  require 'octokit/enterprise_admin_client/license'
6
+ require 'octokit/enterprise_admin_client/orgs'
6
7
  require 'octokit/enterprise_admin_client/search_indexing'
7
8
  require 'octokit/enterprise_admin_client/users'
8
9
 
@@ -22,6 +23,7 @@ module Octokit
22
23
  include Octokit::Warnable
23
24
  include Octokit::EnterpriseAdminClient::AdminStats
24
25
  include Octokit::EnterpriseAdminClient::License
26
+ include Octokit::EnterpriseAdminClient::Orgs
25
27
  include Octokit::EnterpriseAdminClient::SearchIndexing
26
28
  include Octokit::EnterpriseAdminClient::Users
27
29
 
@@ -0,0 +1,25 @@
1
+ module Octokit
2
+ class EnterpriseAdminClient
3
+
4
+ # Methods for the Enterprise Orgs API
5
+ #
6
+ # @see https://developer.github.com/v3/enterprise/orgs/
7
+ module Orgs
8
+
9
+ # Create a new organization on the instance.
10
+ #
11
+ # @param login [String] The organization's username.
12
+ # @param admin [String] The login of the user who will manage this organization.
13
+ # @param options [Hash] A set of options.
14
+ # @option options [String] :profile_name The organization's display name.
15
+ # @return [nil]
16
+ # @see https://developer.github.com/v3/enterprise/orgs/#create-an-organization
17
+ # @example
18
+ # @admin_client.create_organization('SuchAGreatOrg', 'gjtorikian')
19
+ def create_organization(login, admin, options = {})
20
+ post "admin/organizations", options
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -5,6 +5,19 @@ module Octokit
5
5
  #
6
6
  # @see https://developer.github.com/v3/users/administration/
7
7
  module Users
8
+ # Create a new user.
9
+ #
10
+ # @param login [String] The user's username.
11
+ # @param email [String] The user's email address.
12
+ # @see https://developer.github.com/v3/users/administration/#create-a-new-user
13
+ # @example
14
+ # @admin_client.create_user('foobar', 'notreal@foo.bar')
15
+ def create_user(login, email, options = {})
16
+ options[:login] = login
17
+ options[:email] = email
18
+ post "admin/users", options
19
+ end
20
+
8
21
  # Promote an ordinary user to a site administrator
9
22
  #
10
23
  # @param user [String] Username of the user to promote.
@@ -27,6 +40,18 @@ module Octokit
27
40
  boolean_from_response :delete, "users/#{user}/site_admin", options
28
41
  end
29
42
 
43
+ # Rename a user.
44
+ #
45
+ # @param old_login [String] The user's old username.
46
+ # @param new_login [String] The user's new username.
47
+ # @see https://developer.github.com/v3/users/administration/#rename-an-existing-user
48
+ # @example
49
+ # @admin_client.rename_user('foobar', 'foofoobar')
50
+ def rename_user(old_login, new_login, options = {})
51
+ options[:login] = new_login
52
+ patch "admin/users/#{old_login}", options
53
+ end
54
+
30
55
  # Suspend a user.
31
56
  #
32
57
  # @param user [String] Username of the user to suspend.
@@ -48,6 +73,46 @@ module Octokit
48
73
  def unsuspend(user, options = {})
49
74
  boolean_from_response :delete, "users/#{user}/suspended", options
50
75
  end
76
+
77
+ # Creates an impersonation OAuth token.
78
+ #
79
+ # @param login [String] The user to create a token for.
80
+ # @param options [Array<String>] :scopes The scopes to apply.
81
+ # @see https://developer.github.com/v3/users/administration/#create-an-impersonation-oauth-token
82
+ # @example
83
+ # @admin_client.create_impersonation_token('foobar', {:scopes => ['repo:write']})
84
+ def create_impersonation_token(login, options = {})
85
+ post "admin/users/#{login}/authorizations", options
86
+ end
87
+
88
+ # Deletes an impersonation OAuth token.
89
+ #
90
+ # @param login [String] The user whose token should be deleted.
91
+ # @see https://developer.github.com/v3/users/administration/#delete-an-impersonation-oauth-token
92
+ # @example
93
+ # @admin_client.delete_impersonation_token('foobar')
94
+ def delete_impersonation_token(login, options = {})
95
+ boolean_from_response :delete, "admin/users/#{login}/authorizations", options
96
+ end
97
+
98
+ # Lists all the public SSH keys.
99
+ #
100
+ # @see https://developer.github.com/v3/users/administration/#list-all-public-keys
101
+ # @example
102
+ # @admin_client.list_all_keys
103
+ def list_all_keys(options = {})
104
+ get "admin/keys", options
105
+ end
106
+
107
+ # Deletes a public SSH keys.
108
+ #
109
+ # @param [id] Number The ID of the key to delete.
110
+ # @see https://developer.github.com/v3/users/administration/#delete-a-public-key
111
+ # @example
112
+ # @admin_client.delete_key(1)
113
+ def delete_key(id, options = {})
114
+ boolean_from_response :delete, "admin/keys/#{id}", options
115
+ end
51
116
  end
52
117
  end
53
118
  end
@@ -0,0 +1,27 @@
1
+ module Octokit
2
+
3
+ # Default setup options for preview features
4
+ module Preview
5
+
6
+ PREVIEW_TYPES = {
7
+ :migrations => 'application/vnd.github.wyandotte-preview+json'.freeze,
8
+ :licenses => 'application/vnd.github.drax-preview+json'.freeze
9
+ }
10
+
11
+ def ensure_api_media_type(type, options)
12
+ if options[:accept].nil?
13
+ options[:accept] = PREVIEW_TYPES[type]
14
+ warn_preview(:migrations)
15
+ end
16
+ options
17
+ end
18
+
19
+ def warn_preview(type)
20
+ warn <<-EOS
21
+ WARNING: The preview version of the #{type.to_s.capitalize} API is not yet suitable for production use.
22
+ You can avoid this message by supplying an appropriate media type in the 'Accept' request
23
+ header.
24
+ EOS
25
+ end
26
+ end
27
+ end
@@ -5,11 +5,11 @@ module Octokit
5
5
 
6
6
  # Current minor release.
7
7
  # @return [Integer]
8
- MINOR = 0
8
+ MINOR = 1
9
9
 
10
10
  # Current patch level.
11
11
  # @return [Integer]
12
- PATCH = 1
12
+ PATCH = 0
13
13
 
14
14
  # Full release version.
15
15
  # @return [String]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octokit
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wynn Netherland
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-06-29 00:00:00.000000000 Z
13
+ date: 2015-08-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -105,6 +105,7 @@ files:
105
105
  - lib/octokit/enterprise_admin_client.rb
106
106
  - lib/octokit/enterprise_admin_client/admin_stats.rb
107
107
  - lib/octokit/enterprise_admin_client/license.rb
108
+ - lib/octokit/enterprise_admin_client/orgs.rb
108
109
  - lib/octokit/enterprise_admin_client/search_indexing.rb
109
110
  - lib/octokit/enterprise_admin_client/users.rb
110
111
  - lib/octokit/enterprise_management_console_client.rb
@@ -113,6 +114,7 @@ files:
113
114
  - lib/octokit/gist.rb
114
115
  - lib/octokit/middleware/follow_redirects.rb
115
116
  - lib/octokit/organization.rb
117
+ - lib/octokit/preview.rb
116
118
  - lib/octokit/rate_limit.rb
117
119
  - lib/octokit/repo_arguments.rb
118
120
  - lib/octokit/repository.rb