Skip to main content

HttpApi

Struct HttpApi 

Source
pub struct HttpApi {
    pub(crate) http: Http,
}
Expand description

GitHub’s HTTP implementation of super::Api.

Debug is derived, which stays safe because the transport’s token redacts itself.

Fields§

§http: Http

Implementations§

Source§

impl HttpApi

Source

async fn read_actions<R: for<'a> Facet<'a>>( &self, repository: &RepoRef, route: &str, unavailable: Option<u16>, ) -> Result<Option<R>, ForgeError>

Source

async fn put_actions( &self, repository: &RepoRef, route: &str, body: String, ) -> Result<(), ForgeError>

Source§

impl HttpApi

Source

pub(crate) async fn tag_commit( &self, repository: &RepoRef, tag: &str, ) -> Result<Option<String>, ForgeError>

Source

pub(crate) async fn open_pull_request_body( &self, repository: &RepoRef, head: &str, base: &str, ) -> Result<Option<String>, ForgeError>

Read the body of the unique open pull request for head and base.

Source

async fn open_pull_request( &self, repository: &RepoRef, head: &str, base: &str, ) -> Result<Option<PullWire>, ForgeError>

Source

async fn pulls( &self, repository: &RepoRef, state: &str, head: &str, base: &str, ) -> Result<Vec<PullWire>, ForgeError>

Source

pub(crate) async fn ensure_pull_request( &self, repository: &RepoRef, head: &str, base: &str, title: &str, body: &str, ) -> Result<(), ForgeError>

Create the proposal pull request, or update its title and body.

Source

pub(crate) async fn release_by_tag( &self, repository: &RepoRef, tag: &str, ) -> Result<Option<RemoteRelease>, ForgeError>

Read a release by its tag.

The tag route serves only published releases and a draft has no tag yet, so this lists the releases and matches on tag_name.

Source

pub(crate) async fn create_draft_release( &self, repository: &RepoRef, tag: &str, target_commit: &str, title: &str, notes: &str, ) -> Result<u64, ForgeError>

Create a draft release and return its stable ID.

Source

pub(crate) async fn assets( &self, repository: &RepoRef, release_id: u64, ) -> Result<Vec<RemoteAsset>, ForgeError>

List all release assets, including size and server-reported digest.

Source

pub(crate) async fn download_asset( &self, repository: &RepoRef, asset: &RemoteAsset, ) -> Result<Vec<u8>, ForgeError>

Download an existing asset for digest verification when GitHub omitted its server-side digest.

Only the asset route with an octet-stream Accept header serves the assets of draft releases and private repositories. It redirects to storage.

Source

pub(crate) async fn upload_asset( &self, repository: &RepoRef, release_id: u64, filename: &str, bytes: Vec<u8>, ) -> Result<(), ForgeError>

Upload one asset to an existing draft release.

§Errors

Returns a rejection for an invalid asset filename and an unsupported error if the release is already published.

Source

pub(crate) async fn delete_asset( &self, repository: &RepoRef, asset_id: u64, ) -> Result<(), ForgeError>

Delete one release asset.

Source

pub(crate) async fn publish_release( &self, repository: &RepoRef, release_id: u64, ) -> Result<(), ForgeError>

Publish a fully staged draft.

§Errors

Returns an unsupported error if the release is already published.

Source§

impl HttpApi

Source

pub(super) async fn put_switch( &self, repository: &RepoRef, name: &str, enabled: bool, ) -> Result<(), ForgeError>

Source§

impl HttpApi

Source

pub fn new(base: &Url, token: Token) -> Result<Self, TransportBuildError>

Create a GitHub REST client rooted at base (normally https://api.github.com).

§Errors

Returns an error if the underlying HTTP client fails to build.

Source

pub fn with_retry(self, retry: RetryPolicy) -> Self

Replace the retry policy, which keeps tests from sleeping.

Source

async fn send<T: for<'a> Facet<'a>>( &self, method: Method, path: &str, body: Option<String>, ) -> Result<T, ForgeError>

Source

async fn optional<T: for<'a> Facet<'a>>( &self, path: &str, ) -> Result<Option<T>, ForgeError>

A GET that reads a missing resource as None.

Source

async fn empty( &self, method: Method, path: &str, body: Option<String>, ) -> Result<(), ForgeError>

Source

async fn paged<T: for<'a> Facet<'a>>( &self, path: &str, ) -> Result<Vec<T>, ForgeError>

Source

async fn paged_in<R: for<'a> Facet<'a>, T>( &self, path: &str, page_size: usize, items: fn(R) -> Vec<T>, ) -> Result<Vec<T>, ForgeError>

Trait Implementations§

Source§

impl AccessApi for HttpApi

Source§

async fn add_collaborator( &self, repository: &RepoRef, user: &UserName, permission: &Permission, ) -> Result<(), ForgeError>

Grant user the given permission, which invites them if needed.
Source§

async fn add_team( &self, repository: &RepoRef, slug: &str, permission: &Permission, ) -> Result<(), ForgeError>

Grant the team with this slug the given permission on the repository.
Source§

async fn cancel_invitation( &self, repository: &RepoRef, id: u64, ) -> Result<(), ForgeError>

Cancel the pending invitation id.
Source§

async fn collaborators( &self, repository: &RepoRef, ) -> Result<Vec<Collaborator>, ForgeError>

Read the repository’s direct collaborators, without inherited access.
Source§

async fn current_user(&self) -> Result<String, ForgeError>

Read the login of the authenticated user.
Source§

async fn user_teams(&self) -> Result<Vec<Membership>, ForgeError>

Read the teams the authenticated user belongs to, in any organization.
Source§

async fn invitations( &self, repository: &RepoRef, ) -> Result<Vec<Invitation>, ForgeError>

Read the repository’s pending invitations.
Source§

async fn organization_teams( &self, organization: &str, ) -> Result<Vec<Team>, ForgeError>

Read the teams available for assignment at organization.
Source§

async fn owner_kind(&self, owner: &str) -> Result<OwnerKind, ForgeError>

Read whether owner is an organization or a personal account.
Source§

async fn remove_collaborator( &self, repository: &RepoRef, user: &UserName, ) -> Result<(), ForgeError>

Remove user’s direct grant on the repository.
Source§

async fn remove_team( &self, repository: &RepoRef, slug: &str, ) -> Result<(), ForgeError>

Remove the direct grant of the team with this slug on the repository.
Source§

async fn teams(&self, repository: &RepoRef) -> Result<Vec<Team>, ForgeError>

Read the repository’s current direct team grants.
Source§

async fn update_invitation( &self, repository: &RepoRef, id: u64, permission: &Permission, ) -> Result<(), ForgeError>

Change the permission of the pending invitation id.
Source§

impl ActionsApi for HttpApi

Source§

async fn actions_cache( &self, repository: &RepoRef, ) -> Result<Option<Cache>, ForgeError>

Read the cache limits, or None when GitHub reports the endpoint unavailable.
Source§

async fn actions_group<G: ActionsGroup>( &self, repository: &RepoRef, ) -> Result<Option<G>, ForgeError>

Read one settings group, or None when GitHub reports the endpoint unavailable.
Source§

async fn set_actions_cache( &self, repository: &RepoRef, group: &Cache, ) -> Result<(), ForgeError>

Replace the cache limits.
Source§

async fn set_actions_group<G: ActionsGroup>( &self, repository: &RepoRef, group: &G, ) -> Result<(), ForgeError>

Replace one settings group.
Source§

impl AutolinksApi for HttpApi

Read the repository’s autolinks.
Create an autolink.
Delete the autolink id.
Source§

impl Clone for HttpApi

Source§

fn clone(&self) -> HttpApi

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CustomPropertiesApi for HttpApi

Source§

async fn custom_property_values( &self, repository: &RepoRef, ) -> Result<Option<Vec<PropertyEntry>>, ForgeError>

Read the custom property values, or None when the repository has no custom properties endpoint.
Source§

async fn set_custom_property_values( &self, repository: &RepoRef, entries: &[PropertyEntry], ) -> Result<(), ForgeError>

Set or clear several custom property values in one request.
Source§

impl Debug for HttpApi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl EnvironmentsApi for HttpApi

Source§

async fn branch_policies( &self, repository: &RepoRef, environment: &str, ) -> Result<Vec<BranchPolicy>, ForgeError>

Read the branch policies of environment.
Source§

async fn create_branch_policy( &self, repository: &RepoRef, environment: &str, policy: &Policy, ) -> Result<(), ForgeError>

Add a branch policy to environment.
Source§

async fn delete_branch_policy( &self, repository: &RepoRef, environment: &str, id: u64, ) -> Result<(), ForgeError>

Remove the branch policy id from environment.
Source§

async fn delete_environment( &self, repository: &RepoRef, environment: &str, ) -> Result<(), ForgeError>

Delete environment.
Source§

async fn environments( &self, repository: &RepoRef, ) -> Result<Vec<Environment>, ForgeError>

Read the repository’s environments, without their branch policies.
Source§

async fn put_environment( &self, repository: &RepoRef, environment: &str, settings: &EnvironmentBody, ) -> Result<(), ForgeError>

Create environment or replace its settings.
Source§

impl LabelsApi for HttpApi

Source§

async fn create_label( &self, repository: &RepoRef, name: &str, color: &LabelColor, description: &str, ) -> Result<(), ForgeError>

Create the label name.
Source§

async fn delete_label( &self, repository: &RepoRef, name: &str, ) -> Result<(), ForgeError>

Delete the label name.
Source§

async fn labels(&self, repository: &RepoRef) -> Result<Vec<Label>, ForgeError>

Read every label of the repository.
Source§

async fn update_label( &self, repository: &RepoRef, name: &str, color: &LabelColor, description: &str, ) -> Result<(), ForgeError>

Set the color and description of the label name.
Source§

impl PagesApi for HttpApi

Source§

async fn create_pages( &self, repository: &RepoRef, site: &PagesCreate, ) -> Result<(), ForgeError>

Create the Pages site.
Source§

async fn delete_pages(&self, repository: &RepoRef) -> Result<(), ForgeError>

Delete the Pages site.
Source§

async fn pages(&self, repository: &RepoRef) -> Result<Option<Pages>, ForgeError>

Read the Pages site. None means the repository has no site.
Source§

async fn update_pages( &self, repository: &RepoRef, site: &PagesUpdate, ) -> Result<(), ForgeError>

Update the Pages site.
Source§

impl RepositoryApi for HttpApi

Source§

async fn patch_repository( &self, repository: &RepoRef, patch: &RepositoryPatch, ) -> Result<(), ForgeError>

Write only the changed repository fields.
Source§

async fn replace_topics( &self, repository: &RepoRef, topics: &[String], ) -> Result<(), ForgeError>

Replace the repository’s topic labels wholesale.
Source§

async fn immutable_releases( &self, repository: &RepoRef, ) -> Result<Option<ImmutableReleases>, ForgeError>

Read the immutable-release setting. None means GitHub does not offer it for this repository.
Source§

async fn set_immutable_releases( &self, repository: &RepoRef, enabled: bool, ) -> Result<(), ForgeError>

Enable or disable immutable releases.
Source§

async fn repository( &self, repository: &RepoRef, ) -> Result<Repository, ForgeError>

Read the repository’s current settings.
Source§

impl RulesetsApi for HttpApi

Source§

async fn create_ruleset( &self, repository: &RepoRef, name: &str, ruleset: &Definition, ) -> Result<(), ForgeError>

Create a ruleset with its complete desired configuration.
Source§

async fn delete_ruleset( &self, repository: &RepoRef, id: u64, ) -> Result<(), ForgeError>

Delete the ruleset id.
Source§

async fn rulesets( &self, repository: &RepoRef, ) -> Result<Vec<Ruleset>, ForgeError>

Read the repository’s current rulesets.
Source§

async fn update_ruleset( &self, repository: &RepoRef, id: u64, name: &str, ruleset: &Definition, unmanaged_rules: &[Value], ) -> Result<(), ForgeError>

Replace the ruleset id with its complete desired configuration and the live rules that the configuration cannot declare.
Source§

impl SecurityApi for HttpApi

Source§

async fn automated_security_fixes( &self, repository: &RepoRef, ) -> Result<Option<bool>, ForgeError>

Read whether Dependabot security updates are on. None means GitHub does not answer.
Source§

async fn code_scanning_default_setup( &self, repository: &RepoRef, ) -> Result<Option<CodeScanning>, ForgeError>

Read the code scanning default setup. None means GitHub does not answer.
Source§

async fn patch_code_scanning_default_setup( &self, repository: &RepoRef, patch: &CodeScanningPatch, ) -> Result<(), ForgeError>

Write only the changed code scanning default setup properties.
Source§

async fn patch_security_analysis( &self, repository: &RepoRef, patch: &AnalysisPatch, ) -> Result<(), ForgeError>

Write only the changed security_and_analysis properties.
Source§

async fn private_vulnerability_reporting( &self, repository: &RepoRef, ) -> Result<Option<bool>, ForgeError>

Read whether private vulnerability reporting is on. None means GitHub does not answer.
Source§

async fn set_automated_security_fixes( &self, repository: &RepoRef, enabled: bool, ) -> Result<(), ForgeError>

Turn Dependabot security updates on or off.
Source§

async fn set_private_vulnerability_reporting( &self, repository: &RepoRef, enabled: bool, ) -> Result<(), ForgeError>

Turn private vulnerability reporting on or off.
Source§

async fn set_vulnerability_alerts( &self, repository: &RepoRef, enabled: bool, ) -> Result<(), ForgeError>

Turn Dependabot alerts on or off.
Source§

async fn vulnerability_alerts( &self, repository: &RepoRef, ) -> Result<Option<bool>, ForgeError>

Read whether Dependabot alerts are on. None means GitHub does not answer.
Source§

impl VariablesApi for HttpApi

Source§

async fn create_variable( &self, repository: &RepoRef, scope: &VariableScope, variable: &VariableBody, ) -> Result<(), ForgeError>

Create an Actions variable.
Source§

async fn delete_variable( &self, repository: &RepoRef, scope: &VariableScope, name: &str, ) -> Result<(), ForgeError>

Delete the Actions variable name.
Source§

async fn update_variable( &self, repository: &RepoRef, scope: &VariableScope, variable: &VariableBody, ) -> Result<(), ForgeError>

Change the value of an Actions variable.
Source§

async fn variables( &self, repository: &RepoRef, scope: &VariableScope, ) -> Result<Vec<Variable>, ForgeError>

Read the Actions variables in scope.
Source§

impl WebhooksApi for HttpApi

Source§

async fn create_webhook( &self, repository: &RepoRef, webhook: &WebhookBody, ) -> Result<(), ForgeError>

Create a webhook.
Source§

async fn delete_webhook( &self, repository: &RepoRef, id: u64, ) -> Result<(), ForgeError>

Delete the webhook id.
Source§

async fn update_webhook( &self, repository: &RepoRef, id: u64, webhook: &WebhookPatch, ) -> Result<(), ForgeError>

Update the webhook id.
Source§

async fn webhooks( &self, repository: &RepoRef, ) -> Result<Vec<Webhook>, ForgeError>

Read the repository’s webhooks.

Auto Trait Implementations§

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> Api for T

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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>,

Source§

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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