Skip to content

Commit

Permalink
Implement new "create orgs" admin API
Browse files Browse the repository at this point in the history
  • Loading branch information
gjtorikian committed Jul 30, 2015
1 parent fd161f1 commit 02685ee
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/octokit/enterprise_admin_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'octokit/warnable'
require 'octokit/enterprise_admin_client/admin_stats'
require 'octokit/enterprise_admin_client/license'
require 'octokit/enterprise_admin_client/orgs'
require 'octokit/enterprise_admin_client/search_indexing'
require 'octokit/enterprise_admin_client/users'

Expand All @@ -22,6 +23,7 @@ class EnterpriseAdminClient
include Octokit::Warnable
include Octokit::EnterpriseAdminClient::AdminStats
include Octokit::EnterpriseAdminClient::License
include Octokit::EnterpriseAdminClient::Orgs
include Octokit::EnterpriseAdminClient::SearchIndexing
include Octokit::EnterpriseAdminClient::Users

Expand Down
25 changes: 25 additions & 0 deletions lib/octokit/enterprise_admin_client/orgs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Octokit
class EnterpriseAdminClient

# Methods for the Enterprise Orgs API
#
# @see https://developer.github.com/v3/enterprise/orgs/
module Orgs

# Create a new organization on the instance.
#
# options [Hash] A set of options.
# @option options [String] :login The organization's username.
# @option options [String] :admin The login of the user who will manage this organization.
# @option options [String] :profile_name The organization's display name.
# @return [nil]
# @see https://developer.github.com/v3/enterprise/orgs/#create-an-organization
# @example
# @admin_client.create_organization({:login => 'GitHub', :admin => 'monalisaoctocat'})
def create_organization(options)
post "admin/organizations", options
end

end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"http_interactions":[{"request":{"method":"post","uri":"<<ENTERPRISE_HOSTNAME>>admin/organizations","body":{"encoding":"UTF-8","base64_string":"eyJsb2dpbiI6IlN1Y2hBR3JlYXRPcmciLCJhZG1pbiI6Ijw8RU5URVJQUklT\nRV9HSVRIVUJfTE9HSU4+PiJ9\n"},"headers":{"User-Agent":["Octokit Ruby Gem 4.0.1"],"Accept":["application/vnd.github.v3+json"],"Content-Type":["application/json"],"Authorization":["token <<ENTERPRISE_ACCESS_TOKEN>>"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":201,"message":"Created"},"headers":{"Server":["GitHub.com"],"Date":["Thu, 30 Jul 2015 05:50:55 GMT"],"Content-Type":["application/json; charset=utf-8"],"Content-Length":["433"],"Status":["201 Created"],"Cache-Control":["private, max-age=60, s-maxage=60"],"Etag":["\"227aec99c94afb9f3c762c8c9c44f5b9\""],"X-Oauth-Scopes":["admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, repo, user"],"X-Accepted-Oauth-Scopes":[""],"Location":["<<ENTERPRISE_HOSTNAME>>orgs/SuchAGreatOrg"],"Vary":["Accept, Authorization, Cookie, X-GitHub-OTP"],"X-Github-Media-Type":["github.v3; format=json"],"X-Xss-Protection":["1; mode=block"],"X-Frame-Options":["deny"],"Content-Security-Policy":["default-src 'none'"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Expose-Headers":["ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"],"Access-Control-Allow-Origin":["*"],"X-Github-Request-Id":["c9acf209-e8c8-4453-9c68-bbde01a216a0"],"Strict-Transport-Security":["max-age=31536000; includeSubdomains; preload"],"X-Content-Type-Options":["nosniff"]},"body":{"encoding":"UTF-8","base64_string":"eyJsb2dpbiI6IlN1Y2hBR3JlYXRPcmciLCJpZCI6NTEzLCJ1cmwiOiI8PEVO\nVEVSUFJJU0VfSE9TVE5BTUU+Pm9yZ3MvU3VjaEFHcmVhdE9yZyIsInJlcG9z\nX3VybCI6Ijw8RU5URVJQUklTRV9IT1NUTkFNRT4+b3Jncy9TdWNoQUdyZWF0\nT3JnL3JlcG9zIiwiZXZlbnRzX3VybCI6Ijw8RU5URVJQUklTRV9IT1NUTkFN\nRT4+b3Jncy9TdWNoQUdyZWF0T3JnL2V2ZW50cyIsIm1lbWJlcnNfdXJsIjoi\nPDxFTlRFUlBSSVNFX0hPU1ROQU1FPj5vcmdzL1N1Y2hBR3JlYXRPcmcvbWVt\nYmVyc3svbWVtYmVyfSIsInB1YmxpY19tZW1iZXJzX3VybCI6Ijw8RU5URVJQ\nUklTRV9IT1NUTkFNRT4+b3Jncy9TdWNoQUdyZWF0T3JnL3B1YmxpY19tZW1i\nZXJzey9tZW1iZXJ9IiwiYXZhdGFyX3VybCI6Imh0dHBzOi8vYXZhdGFycy5n\naGUuaW8vdS81MTM/IiwiZGVzY3JpcHRpb24iOm51bGx9\n"},"http_version":null},"recorded_at":"Thu, 30 Jul 2015 05:50:55 GMT"}],"recorded_with":"VCR 2.9.3"}
17 changes: 17 additions & 0 deletions spec/octokit/enterprise_admin_client/orgs_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require "helper"

describe Octokit::EnterpriseAdminClient::Orgs do

before do
Octokit.reset!
@admin_client = enterprise_admin_client
end

describe ".orgs", :vcr do
it "creates a new organization" do
@admin_client.create_organization({:login => 'SuchAGreatOrg', :admin => 'gjtorikian'})
expect(@admin_client.last_response.status).to eq(201)
assert_requested :post, github_enterprise_url("admin/organizations")
end
end # .license
end

0 comments on commit 02685ee

Please sign in to comment.