// Copyright 2013 The go-github AUTHORS. All rights reserved.//// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package githubimport ()// Membership represents the status of a user's membership in an organization or team.typeMembershipstruct { URL *string`json:"url,omitempty"`// State is the user's status within the organization or team. // Possible values are: "active", "pending" State *string`json:"state,omitempty"`// Role identifies the user's role within the organization or team. // Possible values for organization membership: // member - non-owner organization member // admin - organization owner // // Possible values for team membership are: // member - a normal member of the team // maintainer - a team maintainer. Able to add/remove other team // members, promote other team members to team // maintainer, and edit the team’s name and description Role *string`json:"role,omitempty"`// For organization membership, the API URL of the organization. OrganizationURL *string`json:"organization_url,omitempty"`// For organization membership, the organization the membership is for. Organization *Organization`json:"organization,omitempty"`// For organization membership, the user the membership is for. User *User`json:"user,omitempty"`}func ( Membership) () string {returnStringify()}// ListMembersOptions specifies optional parameters to the// OrganizationsService.ListMembers method.typeListMembersOptionsstruct {// If true (or if the authenticated user is not an owner of the // organization), list only publicly visible members. PublicOnly bool`url:"-"`// Filter members returned in the list. Possible values are: // 2fa_disabled, all. Default is "all". Filter string`url:"filter,omitempty"`// Role filters members returned by their role in the organization. // Possible values are: // all - all members of the organization, regardless of role // admin - organization owners // member - non-owner organization members // // Default is "all". Role string`url:"role,omitempty"`ListOptions}// ListMembers lists the members for an organization. If the authenticated// user is an owner of the organization, this will return both concealed and// public members, otherwise it will only return public members.//// GitHub API docs: https://docs.github.com/rest/orgs/members#list-organization-members// GitHub API docs: https://docs.github.com/rest/orgs/members#list-public-organization-members////meta:operation GET /orgs/{org}/members//meta:operation GET /orgs/{org}/public_membersfunc ( *OrganizationsService) ( context.Context, string, *ListMembersOptions) ([]*User, *Response, error) {varstringif != nil && .PublicOnly { = fmt.Sprintf("orgs/%v/public_members", ) } else { = fmt.Sprintf("orgs/%v/members", ) } , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }var []*User , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// IsMember checks if a user is a member of an organization.//// GitHub API docs: https://docs.github.com/rest/orgs/members#check-organization-membership-for-a-user////meta:operation GET /orgs/{org}/members/{username}func ( *OrganizationsService) ( context.Context, , string) (bool, *Response, error) { := fmt.Sprintf("orgs/%v/members/%v", , ) , := .client.NewRequest("GET", , nil)if != nil {returnfalse, nil, } , := .client.Do(, , nil) , := parseBoolResponse()return , , }// IsPublicMember checks if a user is a public member of an organization.//// GitHub API docs: https://docs.github.com/rest/orgs/members#check-public-organization-membership-for-a-user////meta:operation GET /orgs/{org}/public_members/{username}func ( *OrganizationsService) ( context.Context, , string) (bool, *Response, error) { := fmt.Sprintf("orgs/%v/public_members/%v", , ) , := .client.NewRequest("GET", , nil)if != nil {returnfalse, nil, } , := .client.Do(, , nil) , := parseBoolResponse()return , , }// RemoveMember removes a user from all teams of an organization.//// GitHub API docs: https://docs.github.com/rest/orgs/members#remove-an-organization-member////meta:operation DELETE /orgs/{org}/members/{username}func ( *OrganizationsService) ( context.Context, , string) (*Response, error) { := fmt.Sprintf("orgs/%v/members/%v", , ) , := .client.NewRequest("DELETE", , nil)if != nil {returnnil, }return .client.Do(, , nil)}// CancelInvite cancels an organization invitation.//// GitHub API docs: https://docs.github.com/rest/orgs/members#cancel-an-organization-invitation////meta:operation DELETE /orgs/{org}/invitations/{invitation_id}func ( *OrganizationsService) ( context.Context, string, int64) (*Response, error) { := fmt.Sprintf("orgs/%v/invitations/%v", , ) , := .client.NewRequest("DELETE", , nil)if != nil {returnnil, }return .client.Do(, , nil)}// PublicizeMembership publicizes a user's membership in an organization. (A// user cannot publicize the membership for another user.)//// GitHub API docs: https://docs.github.com/rest/orgs/members#set-public-organization-membership-for-the-authenticated-user////meta:operation PUT /orgs/{org}/public_members/{username}func ( *OrganizationsService) ( context.Context, , string) (*Response, error) { := fmt.Sprintf("orgs/%v/public_members/%v", , ) , := .client.NewRequest("PUT", , nil)if != nil {returnnil, }return .client.Do(, , nil)}// ConcealMembership conceals a user's membership in an organization.//// GitHub API docs: https://docs.github.com/rest/orgs/members#remove-public-organization-membership-for-the-authenticated-user////meta:operation DELETE /orgs/{org}/public_members/{username}func ( *OrganizationsService) ( context.Context, , string) (*Response, error) { := fmt.Sprintf("orgs/%v/public_members/%v", , ) , := .client.NewRequest("DELETE", , nil)if != nil {returnnil, }return .client.Do(, , nil)}// ListOrgMembershipsOptions specifies optional parameters to the// OrganizationsService.ListOrgMemberships method.typeListOrgMembershipsOptionsstruct {// Filter memberships to include only those with the specified state. // Possible values are: "active", "pending". State string`url:"state,omitempty"`ListOptions}// ListOrgMemberships lists the organization memberships for the authenticated user.//// GitHub API docs: https://docs.github.com/rest/orgs/members#list-organization-memberships-for-the-authenticated-user////meta:operation GET /user/memberships/orgsfunc ( *OrganizationsService) ( context.Context, *ListOrgMembershipsOptions) ([]*Membership, *Response, error) { := "user/memberships/orgs" , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }var []*Membership , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// GetOrgMembership gets the membership for a user in a specified organization.// Passing an empty string for user will get the membership for the// authenticated user.//// GitHub API docs: https://docs.github.com/rest/orgs/members#get-an-organization-membership-for-the-authenticated-user// GitHub API docs: https://docs.github.com/rest/orgs/members#get-organization-membership-for-a-user////meta:operation GET /orgs/{org}/memberships/{username}//meta:operation GET /user/memberships/orgs/{org}func ( *OrganizationsService) ( context.Context, , string) (*Membership, *Response, error) {varstringif != "" { = fmt.Sprintf("orgs/%v/memberships/%v", , ) } else { = fmt.Sprintf("user/memberships/orgs/%v", ) } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, } := new(Membership) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// EditOrgMembership edits the membership for user in specified organization.// Passing an empty string for user will edit the membership for the// authenticated user.//// GitHub API docs: https://docs.github.com/rest/orgs/members#set-organization-membership-for-a-user// GitHub API docs: https://docs.github.com/rest/orgs/members#update-an-organization-membership-for-the-authenticated-user////meta:operation PUT /orgs/{org}/memberships/{username}//meta:operation PATCH /user/memberships/orgs/{org}func ( *OrganizationsService) ( context.Context, , string, *Membership) (*Membership, *Response, error) {var , stringif != "" { = fmt.Sprintf("orgs/%v/memberships/%v", , ) = "PUT" } else { = fmt.Sprintf("user/memberships/orgs/%v", ) = "PATCH" } , := .client.NewRequest(, , )if != nil {returnnil, nil, } := new(Membership) , := .client.Do(, , )if != nil {returnnil, , }return , , nil}// RemoveOrgMembership removes user from the specified organization. If the// user has been invited to the organization, this will cancel their invitation.//// GitHub API docs: https://docs.github.com/rest/orgs/members#remove-organization-membership-for-a-user////meta:operation DELETE /orgs/{org}/memberships/{username}func ( *OrganizationsService) ( context.Context, , string) (*Response, error) { := fmt.Sprintf("orgs/%v/memberships/%v", , ) , := .client.NewRequest("DELETE", , nil)if != nil {returnnil, }return .client.Do(, , nil)}// ListPendingOrgInvitations returns a list of pending invitations.//// GitHub API docs: https://docs.github.com/rest/orgs/members#list-pending-organization-invitations////meta:operation GET /orgs/{org}/invitationsfunc ( *OrganizationsService) ( context.Context, string, *ListOptions) ([]*Invitation, *Response, error) { := fmt.Sprintf("orgs/%v/invitations", ) , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }var []*Invitation , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// CreateOrgInvitationOptions specifies the parameters to the OrganizationService.Invite// method.typeCreateOrgInvitationOptionsstruct {// GitHub user ID for the person you are inviting. Not required if you provide Email. InviteeID *int64`json:"invitee_id,omitempty"`// Email address of the person you are inviting, which can be an existing GitHub user. // Not required if you provide InviteeID Email *string`json:"email,omitempty"`// Specify role for new member. Can be one of: // * admin - Organization owners with full administrative rights to the // organization and complete access to all repositories and teams. // * direct_member - Non-owner organization members with ability to see // other members and join teams by invitation. // * billing_manager - Non-owner organization members with ability to // manage the billing settings of your organization. // Default is "direct_member". Role *string`json:"role,omitempty"` TeamID []int64`json:"team_ids,omitempty"`}// CreateOrgInvitation invites people to an organization by using their GitHub user ID or their email address.// In order to create invitations in an organization,// the authenticated user must be an organization owner.//// GitHub API docs: https://docs.github.com/rest/orgs/members#create-an-organization-invitation////meta:operation POST /orgs/{org}/invitationsfunc ( *OrganizationsService) ( context.Context, string, *CreateOrgInvitationOptions) (*Invitation, *Response, error) { := fmt.Sprintf("orgs/%v/invitations", ) , := .client.NewRequest("POST", , )if != nil {returnnil, nil, }var *Invitation , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// ListOrgInvitationTeams lists all teams associated with an invitation. In order to see invitations in an organization,// the authenticated user must be an organization owner.//// GitHub API docs: https://docs.github.com/rest/orgs/members#list-organization-invitation-teams////meta:operation GET /orgs/{org}/invitations/{invitation_id}/teamsfunc ( *OrganizationsService) ( context.Context, , string, *ListOptions) ([]*Team, *Response, error) { := fmt.Sprintf("orgs/%v/invitations/%v/teams", , ) , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }var []*Team , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// ListFailedOrgInvitations returns a list of failed invitations.//// GitHub API docs: https://docs.github.com/rest/orgs/members#list-failed-organization-invitations////meta:operation GET /orgs/{org}/failed_invitationsfunc ( *OrganizationsService) ( context.Context, string, *ListOptions) ([]*Invitation, *Response, error) { := fmt.Sprintf("orgs/%v/failed_invitations", ) , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }var []*Invitation , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.