123456789_123456789_123456789_123456789_123456789_

Module: Octokit::Client::Organizations

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/octokit/client/organizations.rb

Overview

Methods for the Organizations API

Instance Method Summary

Instance Method Details

#add_team_member(team_id, user, options = {}) ⇒ Boolean

Add team member

Requires authenticated organization owner or member with team admin permission.

Examples:

@client.add_team_member(100000, 'pengwynn')
# Opt-in to future behavior for this endpoint. Adds the member to the
# team if they're already an org member. If not, the method will return
# 422 and indicate the user should call the new Team Membership endpoint.
@client.add_team_member \
  100000,
  'pengwynn',
  :accept => "application/vnd.github.the-wasp-preview+json"

Parameters:

  • team_id (Integer)

    Team id.

  • user (String)

    GitHub username of new team member.

Returns:

  • (Boolean)

    True on successful addition, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 428

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.
  boolean_from_response :put, "teams/#{team_id}/members/#{user}", options.merge({ name: user })
end

#add_team_membership(team_id, user, options = {}) ⇒ Sawyer::Resource

Add or invite a user to a team

Examples:

Check if a user has a membership for a team

@client.add_team_membership(1234, 'pengwynn')

Parameters:

  • team_id (Integer)

    Team id.

  • user (String)

    GitHub username of the user to invite.

Returns:

  • (Sawyer::Resource)

    Hash of team membership info

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 649

def add_team_membership(team_id, user, options = {})
  put "teams/#{team_id}/memberships/#{user}", options
end

#add_team_repo(team_id, repo, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 543

alias add_team_repo add_team_repository

#add_team_repository(team_id, repo, options = {}) ⇒ Boolean Also known as: #add_team_repo

Add team repository

This can also be used to update the permission of an existing team

Requires authenticated user to be an owner of the organization that the team is associated with. Also, the repo must be owned by the organization, or a direct form of a repo owned by the organization.

Examples:

@client.add_team_repository(100000, 'github/developer.github.com')
@client.add_team_repo(100000, 'github/developer.github.com')

Add a team with admin permissions

@client.add_team_repository(100000, 'github/developer.github.com', permission: 'admin')

Parameters:

  • team_id (Integer)

    Team id.

  • repo (String, Hash, Repository)

    A GitHub repository.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :permission (String)

    The permission to grant the team. Only valid on organization-owned repositories. Can be one of: pull, push, or admin. If not specified, the team's permission attribute will be used to determine what permission to grant the team on this repository.

Returns:

  • (Boolean)

    True if successful, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 540

def add_team_repository(team_id, repo, options = {})
  boolean_from_response :put, "teams/#{team_id}/repos/#{Repository.new(repo)}", options
end

#all_organizations(options = {}) ⇒ Array<Sawyer::Resource> Also known as: #all_orgs

List all GitHub organizations

This provides a list of every organization, in the order that they were created.

::Octokit::Organization that you’ve seen.

Parameters:

  • options (Hash) (defaults to: {})

    Optional options.

Options Hash (options):

  • :since (Integer)

    The integer ID of the last

Returns:

  • (Array<Sawyer::Resource>)

    List of GitHub organizations.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 100

def all_organizations(options = {})
  paginate 'organizations', options
end

#all_orgs(options = {})

Alias for #all_organizations.

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 103

alias all_orgs all_organizations

#billing_actions(org) ⇒ Sawyer::Resource

Get GitHub Actions billing for an organization

Requires authenticated organization owner.

Examples:

@client.billing_actions('github')

Parameters:

Returns:

  • (Sawyer::Resource)

    Hash representing GitHub Actions billing for an organization.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 815

def billing_actions(org)
  get "#{Organization.path(org)}/settings/billing/actions"
end

#child_teams(team_id, options = {}) ⇒ Sawyer::Resource

List child teams

Requires authenticated organization member.

Examples:

@client.child_teams(100000, :accept => "application/vnd.github.hellcat-preview+json")

Parameters:

  • team_id (Integer)

    Team id.

Returns:

  • (Sawyer::Resource)

    Hash representing team.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 350

def child_teams(team_id, options = {})
  options = ensure_api_media_type(:nested_teams, options)
  paginate "teams/#{team_id}/teams", options
end

#conceal_membership(org, user, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 613

alias conceal_membership unpublicize_membership

#convert_to_outside_collaborator(org, user, options = {}) ⇒ Boolean

Converts an organization member to an outside collaborator

Requires authenticated organization members.

Examples:

@client.convert_to_outside_collaborator('github', 'lizzhale')

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • user (String)

    GitHub username to be removed as outside collaborator

Returns:

  • (Boolean)

    Return true if outside collaborator removed from organization, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 268

def convert_to_outside_collaborator(org, user, options = {})
  boolean_from_response :put, "#{Organization.path org}/outside_collaborators/#{user}", options
end

#create_team(org, options = {}) ⇒ Sawyer::Resource

Create team

Requires authenticated organization owner.

Examples:

@client.create_team('github', {
  :name => 'Designers',
  :repo_names => ['github/dotfiles']
})

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (String)

    Team name.

  • :repo_names (Array<String>)

    Repositories for the team.

  • :maintainers (Array<String>)

    Maintainers for the team.

  • :parent_team_id (Integer)

    ID of a team to set as the parent team.

Returns:

  • (Sawyer::Resource)

    Hash representing new team.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 304

def create_team(org, options = {})
  if options.key?(:permission)
    octokit_warn 'Deprecated: Passing :permission option to #create_team. Assign team repository permission by passing :permission to #add_team_repository instead.'
  end
  if options.key?(:parent_team_id)
    options = ensure_api_media_type(:nested_teams, options)
  end
  post "#{Organization.path org}/teams", options
end

#delete_migration_archive(org, id, options = {})

Deletes a previous migration archive.

Requires authenticated organization owner.

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • id (Integer)

    ID number of the migration.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 787

def delete_migration_archive(org, id, options = {})
  options = ensure_api_media_type(:migrations, options)
  delete "#{Organization.path(org)}/migrations/#{id}/archive", options
end

#delete_team(team_id, options = {}) ⇒ Boolean

Delete team

Requires authenticated organization owner.

Examples:

@client.delete_team(100000)

Parameters:

  • team_id (Integer)

    Team id.

Returns:

  • (Boolean)

    True if deletion successful, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 390

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

#list_organizations(user = nil, options = {})

Alias for #organizations.

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 84

alias list_organizations organizations

#list_orgs(user = nil, options = {})

Alias for #organizations.

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 85

alias list_orgs organizations

#migration_archive_url(org, id, options = {})

Fetches the URL to a migration archive.

Requires authenticated organization owner.

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • id (Integer)

    ID number of the migration.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 772

def migration_archive_url(org, id, options = {})
  options = ensure_api_media_type(:migrations, options)
  url = "#{Organization.path(org)}/migrations/#{id}/archive"

  response = client_without_redirects(options).get(url)
  response.headers['location']
end

#migration_status(org, id, options = {})

Fetches the status of a migration.

Requires authenticated organization owner.

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • id (Integer)

    ID number of the migration.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 760

def migration_status(org, id, options = {})
  options = ensure_api_media_type(:migrations, options)
  get "#{Organization.path(org)}/migrations/#{id}", options
end

#migrations(org, options = {}) ⇒ Array<Sawyer::Resource>

Lists the most recent migrations.

Requires authenticated organization owner.

Parameters:

Returns:

  • (Array<Sawyer::Resource>)

    Array of migration resources.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 748

def migrations(org, options = {})
  options = ensure_api_media_type(:migrations, options)
  paginate "#{Organization.path(org)}/migrations", options
end

#org(org, options = {})

Alias for #organization.

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 21

alias org organization

#org_invitations(org, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 226

alias org_invitations organization_invitations

#org_member?(org, user, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 191

alias org_member? organization_member?

#org_members(org, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 149

alias org_members organization_members

#org_membership(org, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 689

alias org_membership organization_membership

#org_memberships(options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 672

alias org_memberships organization_memberships

#org_public_member?(org, user, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 211

alias org_public_member? organization_public_member?

#org_public_members(org, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 165

alias org_public_members organization_public_members

#org_repos(org, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 129

alias org_repos organization_repositories

#org_repositories(org, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 128

alias org_repositories organization_repositories

#org_teams(org, options = {})

Alias for #organization_teams.

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 286

alias org_teams organization_teams

#organization(org, options = {}) ⇒ Sawyer::Resource Also known as: #org

Get an organization

Examples:

Octokit.organization('github')
Octokit.org('github')

Parameters:

Returns:

  • (Sawyer::Resource)

    Hash representing GitHub organization.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 18

def organization(org, options = {})
  get Organization.path(org), options
end

#organization_invitations(org, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #org_invitations

List pending organization invitations

Requires authenticated organization member.

Examples:

@client.organization_invitations('github')

Parameters:

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing invitations.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 223

def organization_invitations(org, options = {})
  get "#{Organization.path org}/invitations", options
end

#organization_member?(org, user, options = {}) ⇒ Boolean Also known as: #org_member?

Check if a user is a member of an organization.

Use this to check if another user is a member of an organization that you are a member. If you are not in the organization you are checking, use .organization_public_member? instead.

Examples:

Check if a user is in your organization

@client.organization_member?('your_organization', 'pengwynn')
=> false

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • user (String)

    GitHub username of the user to check.

Returns:

  • (Boolean)

    Is a member?

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 183

def organization_member?(org, user, options = {})
  result = boolean_from_response(:get, "#{Organization.path org}/members/#{user}", options)
  if !result && last_response && last_response.status == 302
    boolean_from_response :get, last_response.headers['Location']
  else
    result
  end
end

#organization_members(org, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #org_members

Get organization members

Public members of the organization are returned by default. An authenticated client that is a member of the GitHub organization is required to get private members.

Examples:

Octokit.organization_members('github')
Octokit.org_members('github')

Parameters:

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing users.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 144

def organization_members(org, options = {})
  options = options.dup
  path = 'public_' if options.delete(:public)
  paginate "#{Organization.path org}/#{path}members", options
end

#organization_membership(org, options = {}) ⇒ Sawyer::Resource Also known as: #org_membership

Get an organization membership

Parameters:

  • org (Integer, String)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :user (String)

    The login of the user, otherwise authenticated user.

Returns:

  • (Sawyer::Resource)

    Hash representing the organization membership.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 681

def organization_membership(org, options = {})
  options = options.dup
  if user = options.delete(:user)
    get "#{Organization.path(org)}/memberships/#{user}", options
  else
    get "user/memberships/orgs/#{org}", options
  end
end

#organization_memberships(options = {}) ⇒ Array<Sawyer::Resource> Also known as: #org_memberships

List all organizations memberships for the authenticated user

Returns:

  • (Array<Sawyer::Resource>)

    Array of organizations memberships.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 669

def organization_memberships(options = {})
  paginate 'user/memberships/orgs', options
end

#organization_public_member?(org, user, options = {}) ⇒ Boolean Also known as: #org_public_member?

Check if a user is a public member of an organization.

If you are checking for membership of a user of an organization that you are in, use .organization_member? instead.

Examples:

Check if a user is a hubbernaut

@client.organization_public_member?('github', 'pengwynn')
=> true

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • user (String)

    GitHub username of the user to check.

Returns:

  • (Boolean)

    Is a public member?

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 208

def organization_public_member?(org, user, options = {})
  boolean_from_response :get, "#{Organization.path org}/public_members/#{user}", options
end

#organization_public_members(org, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #org_public_members

Get organization public members

Lists the public members of an organization

Examples:

Octokit.organization_public_members('github')
Octokit.org_public_members('github')

Parameters:

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing users.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 162

def organization_public_members(org, options = {})
  organization_members org, options.merge(public: true)
end

#organization_repositories(org, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #org_repositories, #org_repos

List organization repositories

Public repositories are available without authentication. Private repos require authenticated organization member.

Examples:

Octokit.organization_repositories('github')
Octokit.org_repositories('github')
Octokit.org_repos('github')
@client.org_repos('github', {:type => 'private'})

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id for which to list repos.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :type (String) — default: 'all'

    Filter by repository type. all, public, member, sources, forks, or private.

Returns:

  • (Array<Sawyer::Resource>)

    List of repositories

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 125

def organization_repositories(org, options = {})
  paginate "#{Organization.path org}/repos", options
end

#organization_teams(org, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #org_teams

List teams

Requires authenticated organization member.

Examples:

@client.organization_teams('github')
@client.org_teams('github')

Parameters:

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing teams.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 283

def organization_teams(org, options = {})
  paginate "#{Organization.path org}/teams", options
end

#organizations(user = nil, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #list_organizations, #list_orgs, #orgs

Get organizations for a user.

Nonauthenticated calls to this method will return organizations that the user is a public member.

Use an authenicated client to get both public and private organizations for a user.

Calling this method on a @client will return that users organizations. Private organizations are included only if the @client is authenticated.

Examples:

Octokit.organizations('pengwynn')
@client.organizations('pengwynn')
Octokit.orgs('pengwynn')
Octokit.list_organizations('pengwynn')
Octokit.list_orgs('pengwynn')
@client.organizations

Parameters:

  • user (Integer, String) (defaults to: nil)

    GitHub user login or id of the user to get list of organizations.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing organizations.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 81

def organizations(user = nil, options = {})
  paginate "#{User.path user}/orgs", options
end

#orgs(user = nil, options = {})

Alias for #organizations.

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 86

alias orgs organizations

#outside_collaborators(org, options = {}) ⇒ Array<Sawyer::Resource>

List outside collaborators for an organization

Requires authenticated organization members.

Examples:

@client.outside_collaborators('github')

Parameters:

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing users.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 238

def outside_collaborators(org, options = {})
  paginate "#{Organization.path org}/outside_collaborators", options
end

#publicize_membership(org, user, options = {}) ⇒ Boolean

Publicize a user's membership of an organization

Requires authenticated organization owner.

Examples:

@client.publicize_membership('github', 'pengwynn')

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • user (String)

    GitHub username of user to publicize.

Returns:

  • (Boolean)

    True if publicization successful, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 594

def publicize_membership(org, user, options = {})
  boolean_from_response :put, "#{Organization.path org}/public_members/#{user}", options
end

#remove_org_member(org, user, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 582

alias remove_org_member remove_organization_member

#remove_org_membership(org, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 722

alias remove_org_membership remove_organization_membership

#remove_organization_member(org, user, options = {}) ⇒ Boolean Also known as: #remove_org_member

Remove organization member

Requires authenticated organization owner or member with team admin access.

Examples:

@client.remove_organization_member('github', 'pengwynn')
@client.remove_org_member('github', 'pengwynn')

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • user (String)

    GitHub username of user to remove.

Returns:

  • (Boolean)

    True if removal is successful, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 577

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
  boolean_from_response :delete, "#{Organization.path org}/members/#{user}", options
end

#remove_organization_membership(org, options = {}) ⇒ Boolean Also known as: #remove_org_membership

Remove an organization membership

Parameters:

Returns:

  • (Boolean)

    Success

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 717

def remove_organization_membership(org, options = {})
  options = options.dup
  user = options.delete(:user)
  user && boolean_from_response(:delete, "#{Organization.path(org)}/memberships/#{user}", options)
end

#remove_outside_collaborator(org, user, options = {}) ⇒ Boolean

Remove outside collaborator from an organization

Requires authenticated organization members.

Examples:

@client.remove_outside_collaborator('github', 'lizzhale')

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • user (String)

    GitHub username to be removed as outside collaborator

Returns:

  • (Boolean)

    Return true if outside collaborator removed from organization, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 253

def remove_outside_collaborator(org, user, options = {})
  boolean_from_response :delete, "#{Organization.path org}/outside_collaborators/#{user}", options
end

#remove_team_member(team_id, user, options = {}) ⇒ Boolean

Remove team member

Requires authenticated organization owner or member with team admin permission.

Examples:

@client.remove_team_member(100000, 'pengwynn')

Parameters:

  • team_id (Integer)

    Team id.

  • user (String)

    GitHub username of the user to boot.

Returns:

  • (Boolean)

    True if user removed, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 446

def remove_team_member(team_id, user, options = {})
  boolean_from_response :delete, "teams/#{team_id}/members/#{user}", options
end

#remove_team_membership(team_id, user, options = {}) ⇒ Boolean

Remove team membership

Examples:

@client.remove_team_membership(100000, 'pengwynn')

Parameters:

  • team_id (Integer)

    Team id.

  • user (String)

    GitHub username of the user to boot.

Returns:

  • (Boolean)

    True if user removed, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 661

def remove_team_membership(team_id, user, options = {})
  boolean_from_response :delete, "teams/#{team_id}/memberships/#{user}", options
end

#remove_team_repo(team_id, repo, _options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 563

alias remove_team_repo remove_team_repository

#remove_team_repository(team_id, repo, _options = {}) ⇒ Boolean Also known as: #remove_team_repo

Remove team repository

Removes repository from team. Does not delete the repository.

Requires authenticated organization owner.

Examples:

@client.remove_team_repository(100000, 'github/developer.github.com')
@client.remove_team_repo(100000, 'github/developer.github.com')

Parameters:

  • team_id (Integer)

    Team id.

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Boolean)

    Return true if repo removed from team, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 560

def remove_team_repository(team_id, repo, _options = {})
  boolean_from_response :delete, "teams/#{team_id}/repos/#{Repository.new(repo)}"
end

#start_migration(org, repositories, options = {}) ⇒ Sawyer::Resource

Initiates the generation of a migration archive.

Requires authenticated organization owner.

Examples:

@client.start_migration('github', ['github/dotfiles'])

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • repositories (Array<String>)

    :repositories Repositories for the organization.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :lock_repositories (Boolean, optional)

    Indicates whether repositories should be locked during migration

Returns:

  • (Sawyer::Resource)

    Hash representing the new migration.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 735

def start_migration(org, repositories, options = {})
  options = ensure_api_media_type(:migrations, options)
  options[:repositories] = repositories
  post "#{Organization.path(org)}/migrations", options
end

#team(team_id, options = {}) ⇒ Sawyer::Resource

Get team

Requires authenticated organization member.

Examples:

@client.team(100000)

Parameters:

  • team_id (Integer)

    Team id.

Returns:

  • (Sawyer::Resource)

    Hash representing team.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 323

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

#team_by_name(org, team_slug, options = {}) ⇒ Sawyer::Resource

Get team by name and org

Requires authenticated organization member.

Examples:

@client.team_by_name("github", "justice-league")

Parameters:

Returns:

  • (Sawyer::Resource)

    Hash representing team.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 337

def team_by_name(org, team_slug, options = {})
  get "#{Organization.path(org)}/teams/#{team_slug}", options
end

#team_invitations(team_id, options = {}) ⇒ Array<Sawyer::Resource>

List pending team invitations

Requires authenticated organization member.

Examples:

@client.team_invitations('github')

Parameters:

  • team_id (Integer)

    Team id.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing invitations.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 479

def team_invitations(team_id, options = {})
  get "teams/#{team_id}/invitations", options
end

#team_member?(team_id, user, options = {}) ⇒ Boolean

Check if a user is a member of a team.

Use this to check if another user is a member of a team that you are a member.

Examples:

Check if a user is in your team

@client.team_member?(100000, 'pengwynn')
=> false

Parameters:

  • team_id (Integer)

    Team id.

  • user (String)

    GitHub username of the user to check.

Returns:

  • (Boolean)

    Is a member?

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 465

def team_member?(team_id, user, options = {})
  boolean_from_response :get, "teams/#{team_id}/members/#{user}", options
end

#team_members(team_id, options = {}) ⇒ Array<Sawyer::Resource>

List team members

Requires authenticated organization member.

Examples:

@client.team_members(100000)

Parameters:

  • team_id (Integer)

    Team id.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing users.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 403

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

#team_membership(team_id, user, options = {}) ⇒ Sawyer::Resource

Check if a user has a team membership.

Examples:

Check if a user has a membership for a team

@client.team_membership(1234, 'pengwynn')

Parameters:

  • team_id (Integer)

    Team id.

  • user (String)

    GitHub username of the user to check.

Returns:

  • (Sawyer::Resource)

    Hash of team membership info

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 634

def team_membership(team_id, user, options = {})
  get "teams/#{team_id}/memberships/#{user}", options
end

#team_repo?(team_id, repo, _options = {})

Alias for #team_repository?.

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 514

alias team_repo? team_repository?

#team_repos(team_id, options = {})

Alias for #team_repositories.

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 497

alias team_repos team_repositories

#team_repositories(team_id, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #team_repos

List team repositories

Requires authenticated organization member.

Examples:

@client.team_repositories(100000)
@client.team_repos(100000)

Parameters:

  • team_id (Integer)

    Team id.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing repositories.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 494

def team_repositories(team_id, options = {})
  paginate "teams/#{team_id}/repos", options
end

#team_repository?(team_id, repo, _options = {}) ⇒ Boolean Also known as: #team_repo?

Check if a repo is managed by a specific team

Examples:

@client.team_repository?(8675309, 'octokit/octokit.rb')
@client.team_repo?(8675309, 'octokit/octokit.rb')

Parameters:

  • team_id (Integer)

    Team ID.

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Boolean)

    True if managed by a team. False if not managed by the team OR the requesting user does not have authorization to access the team information.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 511

def team_repository?(team_id, repo, _options = {})
  boolean_from_response :get, "teams/#{team_id}/repos/#{Repository.new(repo)}"
end

#unlock_repository(org, id, repo, options = {})

Unlock a previous migration archive.

Requires authenticated organization owner.

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • id (Integer)

    ID number of the migration.

  • repo (String)

    Name of the repository.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 800

def unlock_repository(org, id, repo, options = {})
  options = ensure_api_media_type(:migrations, options)
  delete "#{Organization.path(org)}/migrations/#{id}/repos/#{repo}/lock", options
end

#unpublicize_membership(org, user, options = {}) ⇒ Boolean Also known as: #conceal_membership

Conceal a user's membership of an organization.

Requires authenticated organization owner.

Examples:

@client.unpublicize_membership('github', 'pengwynn')
@client.conceal_membership('github', 'pengwynn')

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • user (String)

    GitHub username of user to unpublicize.

Returns:

  • (Boolean)

    True of unpublicization successful, false otherwise.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 610

def unpublicize_membership(org, user, options = {})
  boolean_from_response :delete, "#{Organization.path org}/public_members/#{user}", options
end

#update_org(org, values, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 51

alias update_org update_organization

#update_org_membership(org, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 710

alias update_org_membership update_organization_membership

#update_organization(org, values, options = {}) ⇒ Sawyer::Resource Also known as: #update_org

Update an organization.

Requires authenticated client with proper organization permissions.

Examples:

@client.update_organization('github', {
  :billing_email => 'support@github.com',
  :company => 'GitHub',
  :email => 'support@github.com',
  :location => 'San Francisco',
  :name => 'github'
})
@client.update_org('github', {:company => 'Unicorns, Inc.'})

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • values (Hash)

    The updated organization attributes.

Options Hash (values):

  • :billing_email (String)

    Billing email address. This address is not publicized.

  • :company (String)

    Company name.

  • :email (String)

    Publicly visible email address.

  • :location (String)

    Location of organization.

  • :name (String)

    GitHub username for organization.

  • :default_repository_permission (String)

    The default permission members have on organization repositories.

  • :members_can_create_repositories (Boolean)

    Set true to allow members to create repositories on the organization.

Returns:

  • (Sawyer::Resource)

    Hash representing GitHub organization.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 48

def update_organization(org, values, options = {})
  patch Organization.path(org), options.merge(values)
end

#update_organization_membership(org, options = {}) ⇒ Sawyer::Resource Also known as: #update_org_membership

Edit an organization membership

Parameters:

  • org (String, Integer)

    ::Octokit::Organization GitHub login or id.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :role (String)

    The role of the user in the organization.

  • :state (String)

    The state that the membership should be in.

  • :user (String)

    The login of the user, otherwise authenticated user.

Returns:

  • (Sawyer::Resource)

    Hash representing the updated organization membership.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 700

def update_organization_membership(org, options = {})
  options = options.dup
  if user = options.delete(:user)
    options.delete(:state)
    put "#{Organization.path(org)}/memberships/#{user}", options
  else
    options.delete(:role)
    patch "user/memberships/orgs/#{org}", options
  end
end

#update_team(team_id, options = {}) ⇒ Sawyer::Resource

Update team

Requires authenticated organization owner.

Examples:

@client.update_team(100000, {
  :name => 'Front-end Designers',
  :permission => 'push'
})

Parameters:

  • team_id (Integer)

    Team id.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (String)

    Team name.

  • :permission (String)

    Permissions the team has for team repositories.

    pull - team members can pull, but not push to or administer these repositories. push - team members can pull and push, but not administer these repositories. admin - team members can pull, push and administer these repositories.

  • :parent_team_id (Integer)

    ID of a team to set as the parent team.

Returns:

  • (Sawyer::Resource)

    Hash representing updated team.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 374

def update_team(team_id, options = {})
  if options.key?(:parent_team_id)
    options = ensure_api_media_type(:nested_teams, options)
  end
  patch "teams/#{team_id}", options
end

#user_teams(options = {}) ⇒ Array<Sawyer::Resource>

List all teams for the authenticated user across all their orgs

Returns:

  • (Array<Sawyer::Resource>)

    Array of team resources.

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/organizations.rb', line 619

def user_teams(options = {})
  paginate 'user/teams', options
end