pub struct OrgHandler<'octo> { /* private fields */ }Expand description
A client to GitHub’s organization API.
Created with Octocrab::orgs.
Implementations§
Source§impl<'octo> OrgHandler<'octo>
impl<'octo> OrgHandler<'octo>
Sourcepub fn billing(&self) -> ScopedBillingHandler<'octo>
pub fn billing(&self) -> ScopedBillingHandler<'octo>
Handle billing for the organization.
See: https://docs.github.com/en/rest/billing?apiVersion=2022-11-28
Sourcepub fn packages(&self) -> PackagesHandler<'octo>
pub fn packages(&self) -> PackagesHandler<'octo>
Handle packages for the organization.
See: https://docs.github.com/en/rest/packages/packages?apiVersion=2022-11-28
Sourcepub fn codespaces(&self) -> OrgCodespacesHandler<'octo>
pub fn codespaces(&self) -> OrgCodespacesHandler<'octo>
Handle Codespaces for the organization.
See: https://docs.github.com/en/rest/codespaces/organizations?apiVersion=2022-11-28
Sourcepub fn migrations(&self) -> OrgMigrationsHandler<'octo>
pub fn migrations(&self) -> OrgMigrationsHandler<'octo>
Handle migrations for the organization.
See: https://docs.github.com/en/rest/migrations/orgs?apiVersion=2022-11-28
Sourcepub fn dependabot(&self) -> OrgDependabotHandler<'octo>
pub fn dependabot(&self) -> OrgDependabotHandler<'octo>
Handle Dependabot for the organization.
See: https://docs.github.com/en/rest/dependabot?apiVersion=2022-11-28
Sourcepub fn security_advisories(&self) -> OrgSecurityAdvisoriesHandler<'octo>
pub fn security_advisories(&self) -> OrgSecurityAdvisoriesHandler<'octo>
Handle security advisories for the organization.
See: https://docs.github.com/en/rest/security-advisories/repository-advisories#list-repository-security-advisories-for-an-organization
Sourcepub fn secret_scanning(&self) -> OrgSecretScanningAlertsHandler<'_>
pub fn secret_scanning(&self) -> OrgSecretScanningAlertsHandler<'_>
Handle secret scanning alerts for the organization.
See: https://docs.github.com/en/rest/secret-scanning?apiVersion=2022-11-28#list-secret-scanning-alerts-for-an-organization
Sourcepub fn secrets_scanning(&self) -> OrgSecretScanningAlertsHandler<'_>
pub fn secrets_scanning(&self) -> OrgSecretScanningAlertsHandler<'_>
Handle secret scanning alerts for the organization (alias for secret_scanning).
Sourcepub fn code_scanning(&self) -> OrgCodeScanningHandler<'octo, '_>
pub fn code_scanning(&self) -> OrgCodeScanningHandler<'octo, '_>
Handle code scanning alerts for the organization.
See: https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-an-organization
Sourcepub fn code_scannings(&self) -> OrgCodeScanningHandler<'octo, '_>
pub fn code_scannings(&self) -> OrgCodeScanningHandler<'octo, '_>
Handle code scanning alerts for the organization (alias for code_scanning).
Sourcepub fn rulesets(&self) -> OrgRulesetsHandler<'octo, '_>
pub fn rulesets(&self) -> OrgRulesetsHandler<'octo, '_>
Handle rulesets for the organization.
See: https://docs.github.com/en/rest/orgs/rules?apiVersion=2022-11-28
Sourcepub fn hooks(&self) -> OrgHooksHandler<'octo, '_>
pub fn hooks(&self) -> OrgHooksHandler<'octo, '_>
Handle webhooks for the organization.
See: https://docs.github.com/en/rest/orgs/webhooks?apiVersion=2022-11-28
Sourcepub fn custom_properties(&self) -> OrgCustomPropertiesHandler<'octo, '_>
pub fn custom_properties(&self) -> OrgCustomPropertiesHandler<'octo, '_>
Handle custom properties for the organization.
See: https://docs.github.com/en/rest/orgs/custom-properties?apiVersion=2022-11-28
Sourcepub fn roles(&self) -> OrgRolesHandler<'octo, '_>
pub fn roles(&self) -> OrgRolesHandler<'octo, '_>
Handle organization roles.
See: https://docs.github.com/en/rest/orgs/organization-roles?apiVersion=2022-11-28
Sourcepub fn invitations(&self) -> OrgInvitationsHandler<'octo, '_>
pub fn invitations(&self) -> OrgInvitationsHandler<'octo, '_>
Handle invitations for the organization.
See: https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28
Sourcepub fn personal_access_tokens(
&self,
) -> OrgPersonalAccessTokensHandler<'octo, '_>
pub fn personal_access_tokens( &self, ) -> OrgPersonalAccessTokensHandler<'octo, '_>
Handle fine-grained personal access tokens for the organization.
See: https://docs.github.com/en/rest/orgs/personal-access-tokens?apiVersion=2022-11-28
Sourcepub fn list_issues(&self) -> ListOrgIssuesBuilder<'octo, '_, '_>
pub fn list_issues(&self) -> ListOrgIssuesBuilder<'octo, '_, '_>
List organization issues assigned to the authenticated user.
Sourcepub async fn add_or_update_membership(
&self,
username: impl AsRef<str>,
role: Option<Role>,
) -> Result<MembershipInvitation>
pub async fn add_or_update_membership( &self, username: impl AsRef<str>, role: Option<Role>, ) -> Result<MembershipInvitation>
Add or update organization membership
Note
- Only authenticated organization owners can add a member to the organization or update the member’s role.
- If the authenticated user is adding a member to the organization, the invited user will receive an email inviting them to the organization. The user’s membership status will be pending until they accept the invitation.
- Authenticated users can update a user’s membership by passing the role parameter. If the authenticated user changes a member’s role to admin, the affected user will receive an email notifying them that they’ve been made an organization owner. If the authenticated user changes an owner’s role to member, no email will be sent.
let invitation = octocrab.orgs("owner").add_or_update_membership("ferris", None).await?;Sourcepub async fn check_membership(&self, username: impl AsRef<str>) -> Result<bool>
pub async fn check_membership(&self, username: impl AsRef<str>) -> Result<bool>
Check if a user is, publicly or privately, a member of the organization.
assert!(octocrab.orgs("owner").check_membership("ferris").await?);Sourcepub async fn get(&self) -> Result<Organization>
pub async fn get(&self) -> Result<Organization>
Get an organization
To see many of the organization response values, you need to be an
authenticated organization owner with the admin:org scope. When the
value of two_factor_requirement_enabled is true, the organization
requires all members, billing managers, and outside collaborators to
enable two-factor authentication.
let org = octocrab.orgs("owner").get().await?;Sourcepub fn list_repos(&self) -> ListReposBuilder<'_, '_>
pub fn list_repos(&self) -> ListReposBuilder<'_, '_>
List repos for the specified organization.
use octocrab::params;
// Get the least active repos belonging to `owner`.
let page = octocrab::instance()
.orgs("owner")
.list_repos()
// Optional Parameters
.repo_type(params::repos::Type::Sources)
.sort(params::repos::Sort::Pushed)
.direction(params::Direction::Descending)
.per_page(25)
.page(5u32)
// Send the request.
.send()
.await?;Sourcepub fn events(&self) -> ListOrgEventsBuilder<'_, '_>
pub fn events(&self) -> ListOrgEventsBuilder<'_, '_>
List events on this organization.
Takes an optional etag which allows for efficient polling. Here is a quick example to poll a organization’s events.
let mut etag = None;
loop {
let response: Etagged<Page<Event>> = octocrab::instance()
.orgs("owner")
.events()
.etag(etag)
.send()
.await?;
if let Some(page) = response.value {
// do something with the page ...
} else {
println!("No new data received, trying again soon");
}
etag = response.etag;
// add a delay before the next iteration
}Sourcepub async fn create_hook(&self, hook: Hook) -> Result<Hook>
pub async fn create_hook(&self, hook: Hook) -> Result<Hook>
Creates a new webhook for the specified organization.
§Notes
Only authorized users or apps can modify organization webhooks.
§Examples
use octocrab::models::hooks::{Hook, Config as HookConfig, ContentType as HookContentType};
let config = HookConfig {
url: "https://example.com".to_string(),
content_type: Some(HookContentType::Json),
insecure_ssl: None,
secret: None
};
let hook = Hook {
name: "web".to_string(),
config,
..Hook::default()
};
let hook = octocrab.orgs("owner").create_hook(hook).await?;Sourcepub fn list_members(&self) -> ListOrgMembersBuilder<'_, '_>
pub fn list_members(&self) -> ListOrgMembersBuilder<'_, '_>
Sourcepub fn secrets(&self) -> OrgSecretsHandler<'_>
pub fn secrets(&self) -> OrgSecretsHandler<'_>
Handle secrets on the organizaton
let secrets = octocrab.orgs("org").secrets();Sourcepub fn variables(&self) -> OrgVariablesHandler<'_>
pub fn variables(&self) -> OrgVariablesHandler<'_>
Client for GitHub’s organization variables API.
See: https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28
Sourcepub async fn get_interaction_restrictions(&self) -> Result<InteractionLimit>
pub async fn get_interaction_restrictions(&self) -> Result<InteractionLimit>
§Get interaction restrictions for an organization
Shows which type of GitHub user can interact with this organization and when the restriction expires. If there is no restrictions, you will see an empty response.
Fine-grained access tokens for “Get interaction restrictions for an organization”
This endpoint works with the following fine-grained token types:
- GitHub App user access tokens
- GitHub App installation access tokens
- Fine-grained personal access tokens
The fine-grained token must have the following permission set:
- “Administration” organization permissions (read)
Sourcepub async fn set_interaction_restrictions(
&self,
limit_type: InteractionLimitType,
expiry: InteractionLimitExpiry,
) -> Result<InteractionLimit>
pub async fn set_interaction_restrictions( &self, limit_type: InteractionLimitType, expiry: InteractionLimitExpiry, ) -> Result<InteractionLimit>
§Set interaction restrictions for an organization
Temporarily restricts interactions to a certain type of GitHub user in any public repository in the given organization. You must be an organization owner to set these restrictions. Setting the interaction limit at the organization level will overwrite any interaction limits that are set for individual repositories owned by the organization.
Fine-grained access tokens for “Set interaction restrictions for an organization”
This endpoint works with the following fine-grained token types:
- GitHub App user access tokens
- GitHub App installation access tokens
- Fine-grained personal access tokens
The fine-grained token must have the following permission set:
- “Administration” organization permissions (write)
Sourcepub fn copilot(&self) -> CopilotHandler<'octo, '_>
pub fn copilot(&self) -> CopilotHandler<'octo, '_>
Handle copilot-related calls on the organization.
Note: You can also use the top-level Octocrab::copilot().org(...) entry point.
§Examples
let copilot_usage = octocrab.orgs("org").copilot().metrics().await.expect("failed to retrieve usage");Sourcepub async fn remove_interaction_restrictions(&self) -> Result<()>
pub async fn remove_interaction_restrictions(&self) -> Result<()>
§Remove interaction restrictions for an organization
Removes all interaction restrictions from public repositories in the given organization. You must be an organization owner to remove restrictions.
Fine-grained access tokens for “Remove interaction restrictions for an organization”
This endpoint works with the following fine-grained token types:
- GitHub App user access tokens
- GitHub App installation access tokens
- Fine-grained personal access tokens
The fine-grained token must have the following permission set:
- “Administration” organization permissions (write)
async fn run() -> crate::octocrab::Result<()> {
let org_name = "example-org".to_string();
let crab = octocrab::instance();
crab.orgs(org_name).remove_interaction_restrictions().await?;
Ok(())
}Sourcepub fn list_public_members(&self) -> ListPublicMembersBuilder<'octo, '_>
pub fn list_public_members(&self) -> ListPublicMembersBuilder<'octo, '_>
Lists public members of an organization.
Sourcepub async fn check_public_membership(
&self,
username: impl AsRef<str>,
) -> Result<bool>
pub async fn check_public_membership( &self, username: impl AsRef<str>, ) -> Result<bool>
Checks if a user is a public member of an organization.
Sourcepub async fn publicize_membership(
&self,
username: impl AsRef<str>,
) -> Result<()>
pub async fn publicize_membership( &self, username: impl AsRef<str>, ) -> Result<()>
Sets public organization membership for the authenticated user.
Sourcepub async fn conceal_membership(&self, username: impl AsRef<str>) -> Result<()>
pub async fn conceal_membership(&self, username: impl AsRef<str>) -> Result<()>
Removes public organization membership for the authenticated user.
Sourcepub fn list_outside_collaborators(
&self,
) -> ListOutsideCollaboratorsBuilder<'octo, '_>
pub fn list_outside_collaborators( &self, ) -> ListOutsideCollaboratorsBuilder<'octo, '_>
Lists outside collaborators for an organization.
Sourcepub async fn convert_to_outside_collaborator(
&self,
username: impl AsRef<str>,
) -> Result<()>
pub async fn convert_to_outside_collaborator( &self, username: impl AsRef<str>, ) -> Result<()>
Converts an organization member to outside collaborator.
Sourcepub async fn remove_outside_collaborator(
&self,
username: impl AsRef<str>,
) -> Result<()>
pub async fn remove_outside_collaborator( &self, username: impl AsRef<str>, ) -> Result<()>
Removes an outside collaborator from an organization.
Sourcepub fn list_blocked_users(&self) -> ListBlockedUsersBuilder<'octo, '_>
pub fn list_blocked_users(&self) -> ListBlockedUsersBuilder<'octo, '_>
Lists users blocked by an organization.
Sourcepub async fn check_blocked_user(
&self,
username: impl AsRef<str>,
) -> Result<bool>
pub async fn check_blocked_user( &self, username: impl AsRef<str>, ) -> Result<bool>
Checks if a user is blocked by an organization.
Sourcepub async fn block_user(&self, username: impl AsRef<str>) -> Result<()>
pub async fn block_user(&self, username: impl AsRef<str>) -> Result<()>
Blocks a user from an organization.
Sourcepub async fn unblock_user(&self, username: impl AsRef<str>) -> Result<()>
pub async fn unblock_user(&self, username: impl AsRef<str>) -> Result<()>
Unblocks a user from an organization.
Sourcepub async fn list_security_managers(&self) -> Result<Vec<Team>>
pub async fn list_security_managers(&self) -> Result<Vec<Team>>
Lists teams that are security managers for an organization.
Sourcepub async fn add_security_manager_team(
&self,
team_slug: impl AsRef<str>,
) -> Result<()>
pub async fn add_security_manager_team( &self, team_slug: impl AsRef<str>, ) -> Result<()>
Adds a security manager team to an organization.
Sourcepub async fn remove_security_manager_team(
&self,
team_slug: impl AsRef<str>,
) -> Result<()>
pub async fn remove_security_manager_team( &self, team_slug: impl AsRef<str>, ) -> Result<()>
Removes a security manager team from an organization.
Sourcepub async fn set_security_product_enablement(
&self,
product: SecurityProduct,
enablement: SecurityEnablement,
) -> Result<()>
pub async fn set_security_product_enablement( &self, product: SecurityProduct, enablement: SecurityEnablement, ) -> Result<()>
Enables or disables a security feature for an organization.
Sourcepub fn list_installations(&self) -> ListOrgInstallationsBuilder<'octo, '_>
pub fn list_installations(&self) -> ListOrgInstallationsBuilder<'octo, '_>
Lists app installations for an organization.
Sourcepub async fn installation(&self) -> Result<Installation>
pub async fn installation(&self) -> Result<Installation>
Gets an organization installation for the authenticated app.