Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 106 lines (86 sloc) 3.584 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
module Octokit
  class Client
    module Organizations
      def organization(org, options={})
        get("orgs/#{org}", options, 3)
      end
      alias :org :organization

      def update_organization(org, values, options={})
        patch("orgs/#{org}", options.merge({:organization => values}), 3)
      end
      alias :update_org :update_organization

      def organizations(user=nil, options={})
        if user
          get("users/#{user}/orgs", options, 3)
        else
          get("user/orgs", options, 3)
        end
      end
      alias :list_organizations :organizations
      alias :list_orgs :organizations
      alias :orgs :organizations

      def organization_repositories(org=nil, options={})
        get("orgs/#{org}/repos", options, 3)
      end
      alias :org_repositories :organization_repositories
      alias :org_repos :organization_repositories

      def organization_members(org, options={})
        get("orgs/#{org}/members", options, 3)
      end
      alias :org_members :organization_members

      def organization_teams(org, options={})
        get("orgs/#{org}/teams", options, 3)
      end
      alias :org_teams :organization_teams

      def create_team(org, options={})
        post("orgs/#{org}/teams", options, 3)
      end

      def team(team_id, options={})
        get("teams/#{team_id}", options, 3)
      end

      def update_team(team_id, options={})
        patch("teams/#{team_id}", options, 3)
      end

      def delete_team(team_id, options={})
        delete("teams/#{team_id}", options, 3, true, true)
      end

      def team_members(team_id, options={})
        get("teams/#{team_id}/members", options, 3)
      end

      def add_team_member(team_id, user, options={})
        # There's a bug in this API call. The docs say to leave the body blank,
        # but it fails if the body is both blank and the content-length header
        # is not 0.
        put("teams/#{team_id}/members/#{user}", options.merge({:name => user}), 3, true, raw=true).status == 204
      end

      def remove_team_member(team_id, user, options={})
        delete("teams/#{team_id}/members/#{user}", options, 3, true, raw=true).status == 204
      end

      def team_repositories(team_id, options={})
        get("teams/#{team_id}/repos", options, 3)
      end
      alias :team_repos :team_repositories

      def add_team_repository(team_id, repo, options={})
        put("teams/#{team_id}/repos/#{Repository.new(repo)}", options.merge(:name => Repository.new(repo)), 3, true, raw=true).status == 204
      end
      alias :add_team_repo :add_team_repository

      def remove_team_repository(team_id, repo, options={})
        delete("teams/#{team_id}/repos/#{Repository.new(repo)}", options, 3, true, raw=true).status == 204
      end
      alias :remove_team_repo :remove_team_repository

      def remove_organization_member(org, user, options={})
        # this is a synonym for: for team in org.teams: remove_team_member(team.id, user)
        # provided in the GH API v3
        delete("orgs/#{org}/members/#{user}", options, 3, true, raw=true).status == 204
      end
      alias :remove_org_member :remove_organization_member

      def publicize_membership(org, user, options={})
        put("orgs/#{org}/public_members/#{user}", options, 3, true, raw=true).status == 204
      end

      def unpublicize_membership(org, user, options={})
        delete("orgs/#{org}/public_members/#{user}", options, 3, true, raw=true).status == 204
      end
      alias :conceal_membership :unpublicize_membership

    end
  end
end
Something went wrong with that request. Please try again.