pub struct Client<T: Transport = UreqTransport> { /* private fields */ }Expand description
A HackerOne API client.
Generic over its Transport so it can be unit-tested with a mock and
embedded with a custom HTTP stack. The default transport is
UreqTransport.
use hackerone_api::Client;
let client = Client::new("my-api-identifier", "my-api-token");
let me = client.me()?;
println!("{:?}", me.username);Implementations§
Source§impl<T: Transport> Client<T>
impl<T: Transport> Client<T>
Sourcepub fn with_transport(base_url: impl Into<String>, transport: T) -> Self
pub fn with_transport(base_url: impl Into<String>, transport: T) -> Self
Build a client over a custom transport (no credentials yet).
Sourcepub fn with_credentials(
self,
identifier: impl Into<String>,
token: impl Into<String>,
) -> Self
pub fn with_credentials( self, identifier: impl Into<String>, token: impl Into<String>, ) -> Self
Attach HTTP Basic credentials (builder style).
Sourcepub fn programs(&self) -> Result<Page<Program>>
pub fn programs(&self) -> Result<Page<Program>>
GET /v1/me/programs — programs the token can access.
Sourcepub fn program(&self, id: &str) -> Result<Program>
pub fn program(&self, id: &str) -> Result<Program>
GET /v1/programs/{id} — one program by handle or id.
Sourcepub fn structured_scopes(
&self,
program_id: &str,
page: Option<(u32, u32)>,
) -> Result<Page<StructuredScope>>
pub fn structured_scopes( &self, program_id: &str, page: Option<(u32, u32)>, ) -> Result<Page<StructuredScope>>
GET /v1/programs/{id}/structured_scopes — a program’s scopes.
Sourcepub fn reports(&self, query: &ReportQuery) -> Result<Page<Report>>
pub fn reports(&self, query: &ReportQuery) -> Result<Page<Report>>
GET /v1/reports — reports, filtered by query.
Sourcepub fn create_report(&self, report: &CreateReport) -> Result<Report>
pub fn create_report(&self, report: &CreateReport) -> Result<Report>
POST /v1/reports — create a report.
Sourcepub fn add_comment(
&self,
report_id: &str,
message: &str,
) -> Result<Resource<Value>>
pub fn add_comment( &self, report_id: &str, message: &str, ) -> Result<Resource<Value>>
POST /v1/reports/{id}/activities — add a comment.
Sourcepub fn change_state(
&self,
report_id: &str,
state: ReportState,
message: Option<&str>,
) -> Result<Resource<Value>>
pub fn change_state( &self, report_id: &str, state: ReportState, message: Option<&str>, ) -> Result<Resource<Value>>
POST /v1/reports/{id}/state_changes — change a report’s state.
Sourcepub fn weaknesses(&self) -> Result<Page<Weakness>>
pub fn weaknesses(&self) -> Result<Page<Weakness>>
GET /v1/weaknesses — the CWE catalog.
Auto Trait Implementations§
impl<T> Freeze for Client<T>where
T: Freeze,
impl<T> RefUnwindSafe for Client<T>where
T: RefUnwindSafe,
impl<T> Send for Client<T>
impl<T> Sync for Client<T>
impl<T> Unpin for Client<T>where
T: Unpin,
impl<T> UnsafeUnpin for Client<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Client<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more