customclient

package
v0.4.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// GitHubDotCom is the default instance; anything else is self-hosted or a
	// data-residency host.
	GitHubDotCom = "https://github.com"
)

Variables

View Source
var ErrOrganizationNotInEnterprise = errors.New("organization does not belong to the enterprise")

ErrOrganizationNotInEnterprise is the one configuration answer VerifyOrganization gives. Callers key on it rather than on the gRPC code, because a query failure inside the walk carries a code too -- a GraphQL UNPROCESSABLE is classified FailedPrecondition, and status.Code unwraps through %w, so the code alone cannot tell the two apart.

Functions

func EnterpriseGraphQLEndpoint added in v0.4.8

func EnterpriseGraphQLEndpoint(instanceURL string) (*url.URL, error)

EnterpriseGraphQLEndpoint returns the instance's GraphQL URL: api.github.com for GitHub.com, /api/graphql on a self-hosted host.

func NewStatusClassifyingTransport added in v0.4.8

func NewStatusClassifyingTransport(base http.RoundTripper) http.RoundTripper

NewStatusClassifyingTransport wraps base so non-2xx GraphQL responses carry a gRPC code instead of the library's opaque error.

Types

type AppInstallation added in v0.4.8

type AppInstallation struct {
	ID int64 `json:"id"`
}

type Client

type Client struct {
	*uhttp.BaseHttpClient
	// contains filtered or unexported fields
}

used for endpoints not in the go-github library example: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/license?apiVersion=2022-11-28#list-enterprise-consumed-licenses

func New

func New(client *github.Client) *Client

func (*Client) GetEnterpriseInstallation added in v0.4.8

func (c *Client) GetEnterpriseInstallation(ctx context.Context, enterprise string) (*AppInstallation, *v2.RateLimitDescription, error)

GetEnterpriseInstallation returns this app's installation on one enterprise. It needs the app JWT client, not an installation token. https://docs.github.com/en/rest/apps/apps#get-an-enterprise-installation-for-the-authenticated-app

type EnterpriseAdminClient added in v0.4.8

type EnterpriseAdminClient struct {
	// contains filtered or unexported fields
}

EnterpriseAdminClient reads and writes the Owner role of one enterprise. It needs both installation tokens:

  • Enterprise.ownerInfo is null for installation tokens, so owners are read from Organization.enterpriseOwners with the org token.
  • The invitation lookup and mutations need the enterprise token.

Enterprise.members(role: OWNER) is not used: it returns owners of organizations in the enterprise, not owners of the enterprise account.

func NewEnterpriseAdminClient added in v0.4.8

func NewEnterpriseAdminClient(
	instanceURL string,
	enterpriseHTTPClient *http.Client,
	orgHTTPClient *http.Client,
	org string,
) (*EnterpriseAdminClient, error)

NewEnterpriseAdminClient returns the client for one enterprise, with a GraphQL client per installation token.

func (*EnterpriseAdminClient) CancelInvitation added in v0.4.8

func (c *EnterpriseAdminClient) CancelInvitation(ctx context.Context, invitationID string) error

func (*EnterpriseAdminClient) InviteOwner added in v0.4.8

func (c *EnterpriseAdminClient) InviteOwner(ctx context.Context, enterpriseID string, login string) error

InviteOwner sends the Owner invitation a member has to accept.

func (*EnterpriseAdminClient) IsMember added in v0.4.8

func (c *EnterpriseAdminClient) IsMember(
	ctx context.Context,
	enterprise string,
	login string,
) (bool, annotations.Annotations, error)

IsMember reports whether login belongs to the enterprise. Grants() can only see invitations addressed to members.

func (*EnterpriseAdminClient) Members added in v0.4.8

Members returns one page of the enterprise's Members and the next cursor, skipping nodes without a database ID.

func (*EnterpriseAdminClient) OwnerState added in v0.4.8

OwnerState reports whether a login owns the enterprise and whether an Owner invitation is pending. Both are resolved because Revoke clears each.

Owners are paged and matched by login rather than using the owners query argument, which is a search that can lag right after a mutation.

func (*EnterpriseAdminClient) Owners added in v0.4.8

Owners returns one page of the enterprise account's Owners.

func (*EnterpriseAdminClient) PendingOwnerInvitations added in v0.4.8

func (c *EnterpriseAdminClient) PendingOwnerInvitations(
	ctx context.Context,
	enterprise string,
	logins []string,
) (map[string]string, annotations.Annotations, error)

PendingOwnerInvitations returns the pending Owner invitation of each login that has one, in one aliased request. Invitations can't be listed with an installation token, so they're looked up per login.

Logins are passed as variables; only generated aliases reach the query text. NOT_FOUND entries (no invitation) are dropped before classifying the rest.

Dropping them is safe because NOT_FOUND here means absent, not forbidden, and two things establish that rather than assumption. graphQLErrorsCode ranks FORBIDDEN and UNAUTHENTICATED above NOT_FOUND precisely so a credential failure cannot arrive wearing the code a caller reads as absence. And these logins come from the Members query that ran immediately before on this same enterprise token, which would have failed first if the token could not read the enterprise at all. Were that not so, every alias would be dropped and every invitee grant revoked on the next sync.

func (*EnterpriseAdminClient) ResolveEnterpriseNodeID added in v0.4.8

func (c *EnterpriseAdminClient) ResolveEnterpriseNodeID(ctx context.Context, enterprise string) error

ResolveEnterpriseNodeID stores the node ID enterprise mutations take. It also checks that the enterprise is visible to this installation.

func (*EnterpriseAdminClient) UpdateRole added in v0.4.8

func (c *EnterpriseAdminClient) UpdateRole(
	ctx context.Context,
	enterpriseID string,
	login string,
	role githubv4.EnterpriseAdministratorRole,
) error

UpdateRole changes the role of someone who already administers the enterprise. It cannot promote a plain member.

func (*EnterpriseAdminClient) VerifyOrganization added in v0.4.8

func (c *EnterpriseAdminClient) VerifyOrganization(ctx context.Context, enterprise string) error

VerifyOrganization checks that the organization owners are read through belongs to this enterprise. organizations(query:) is a substring search, so every page is read before concluding it is not there.

type EnterpriseConsumedLicense

type EnterpriseConsumedLicense struct {
	TotalSeatsConsumed  int                    `json:"total_seats_consumed"`
	TotalSeatsPurchased int                    `json:"total_seats_purchased"`
	Users               []GitHubEnterpriseUser `json:"users"`
}

https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/license?apiVersion=2022-11-28#list-enterprise-consumed-licenses

type EnterpriseOwnerState added in v0.4.8

type EnterpriseOwnerState struct {
	EnterpriseID        string
	IsOwner             bool
	PendingInvitationID string
}

EnterpriseOwnerState is a user's Owner role and pending Owner invitation, if any.

func (EnterpriseOwnerState) HoldsRole added in v0.4.8

func (s EnterpriseOwnerState) HoldsRole() bool

HoldsRole reports whether C1 should see a grant. C1 has no pending state, so an unaccepted invitation counts.

type EnterpriseUser added in v0.4.8

type EnterpriseUser struct {
	DatabaseID int64
	Login      string
}

EnterpriseUser is a user account as the enterprise reports it.

type GitHubEnterpriseUser

type GitHubEnterpriseUser struct {
	GitHubComLogin                       string   `json:"github_com_login"`
	GitHubComName                        string   `json:"github_com_name"`
	EnterpriseServerUserIDs              []string `json:"enterprise_server_user_ids"`
	GitHubComUser                        bool     `json:"github_com_user"`
	EnterpriseServerUser                 bool     `json:"enterprise_server_user"`
	VisualStudioSubscriptionUser         bool     `json:"visual_studio_subscription_user"`
	LicenseType                          string   `json:"license_type"`
	GitHubComProfile                     string   `json:"github_com_profile"`
	GitHubComMemberRoles                 []string `json:"github_com_member_roles"`
	GitHubComEnterpriseRoles             []string `json:"github_com_enterprise_roles"`
	GitHubComVerifiedDomainEmails        []string `json:"github_com_verified_domain_emails"`
	GitHubComSAMLNameID                  *string  `json:"github_com_saml_name_id"`
	GitHubComOrgsWithPendingInvites      []string `json:"github_com_orgs_with_pending_invites"`
	GitHubComTwoFactorAuth               bool     `json:"github_com_two_factor_auth"`
	GitHubComTwoFactorAuthRequiredByDate string   `json:"github_com_two_factor_auth_required_by_date"`
	GitHubComCostCenter                  *string  `json:"github_com_cost_center"`
	GitHubComCodeSecurityLicenseUser     bool     `json:"github_com_code_security_license_user"`
	GitHubComSecretProtectionLicenseUser bool     `json:"github_com_secret_protection_license_user"`
	GHELicenseActive                     bool     `json:"ghe_license_active"`
	GHELicenseStartDate                  *string  `json:"ghe_license_start_date"`
	GHELicenseEndDate                    string   `json:"ghe_license_end_date"`
	EnterpriseServerPrimaryEmails        []string `json:"enterprise_server_primary_emails"`
	VisualStudioLicenseStatus            *string  `json:"visual_studio_license_status"`
	VisualStudioSubscriptionEmail        *string  `json:"visual_studio_subscription_email"`
	TotalUserAccounts                    int      `json:"total_user_accounts"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL