Struct octocrab::orgs::OrgHandler

source ·
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>

source

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?;
source

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?);
source

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?;
source

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?;
source

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
}
source

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?;
source

pub fn list_members(&self) -> ListOrgMembersBuilder<'_, '_>

Lists members of the specified organization.

§Notes

Only authorized users who belong to the organization can list its members.

§Examples
let org_members = octocrab::instance().orgs("org").list_members().send().await?;
source

pub fn secrets(&self) -> OrgSecretsHandler<'_>

Handle secrets on the organizaton

Auto Trait Implementations§

§

impl<'octo> Freeze for OrgHandler<'octo>

§

impl<'octo> !RefUnwindSafe for OrgHandler<'octo>

§

impl<'octo> Send for OrgHandler<'octo>

§

impl<'octo> Sync for OrgHandler<'octo>

§

impl<'octo> Unpin for OrgHandler<'octo>

§

impl<'octo> !UnwindSafe for OrgHandler<'octo>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> PolicyExt for T
where T: ?Sized,

source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more