VeracodeClient

Struct VeracodeClient 

Source
pub struct VeracodeClient { /* private fields */ }
Expand description

Core Veracode API client.

This struct provides the foundational HTTP client with HMAC authentication for making requests to any Veracode API endpoint.

Implementations§

Source§

impl VeracodeClient

Application-specific methods that build on the core client.

Source

pub async fn get_applications( &self, query: Option<ApplicationQuery>, ) -> Result<ApplicationsResponse, VeracodeError>

Get all applications with optional filtering.

§Arguments
  • query - Optional query parameters to filter the results
§Returns

A Result containing an ApplicationsResponse with the list of applications.

Source

pub async fn get_application( &self, guid: &str, ) -> Result<Application, VeracodeError>

Get a specific application by its GUID.

§Arguments
  • guid - The GUID of the application to retrieve
§Returns

A Result containing the Application details.

Source

pub async fn create_application( &self, request: &CreateApplicationRequest, ) -> Result<Application, VeracodeError>

Create a new application.

§Arguments
  • request - The application creation request containing profile information
§Returns

A Result containing the created Application.

Source

pub async fn update_application( &self, guid: &str, request: &UpdateApplicationRequest, ) -> Result<Application, VeracodeError>

Update an existing application.

§Arguments
  • guid - The GUID of the application to update
  • request - The update request containing the new profile information
§Returns

A Result containing the updated Application.

Source

pub async fn delete_application(&self, guid: &str) -> Result<(), VeracodeError>

Delete an application.

§Arguments
  • guid - The GUID of the application to delete
§Returns

A Result indicating success or failure.

Source

pub async fn get_non_compliant_applications( &self, ) -> Result<Vec<Application>, VeracodeError>

Get applications that failed policy compliance.

§Returns

A Result containing a Vec<Application> of non-compliant applications.

Source

pub async fn get_applications_modified_after( &self, date: &str, ) -> Result<Vec<Application>, VeracodeError>

Get applications modified after a specific date.

§Arguments
  • date - ISO 8601 formatted date string
§Returns

A Result containing a Vec<Application> of applications modified after the date.

Source

pub async fn search_applications_by_name( &self, name: &str, ) -> Result<Vec<Application>, VeracodeError>

Search applications by name.

§Arguments
  • name - The name to search for (partial matches are supported)
§Returns

A Result containing a Vec<Application> of applications matching the name.

Source

pub async fn get_all_applications( &self, ) -> Result<Vec<Application>, VeracodeError>

Get all applications with automatic pagination.

§Returns

A Result containing a Vec<Application> of all applications.

Source

pub async fn get_application_by_name( &self, name: &str, ) -> Result<Option<Application>, VeracodeError>

Get application by name (exact match).

§Arguments
  • name - The exact name of the application to find
§Returns

A Result containing an Option<Application> if found.

Source

pub async fn application_exists_by_name( &self, name: &str, ) -> Result<bool, VeracodeError>

Check if application exists by name.

§Arguments
  • name - The name of the application to check
§Returns

A Result containing a boolean indicating if the application exists.

Source

pub async fn get_app_id_from_guid( &self, guid: &str, ) -> Result<String, VeracodeError>

Get numeric app_id from application GUID.

This is needed for XML API operations that require numeric IDs.

§Arguments
  • guid - The application GUID
§Returns

A Result containing the numeric app_id as a string.

Source

pub async fn create_application_if_not_exists( &self, name: &str, business_criticality: BusinessCriticality, description: Option<String>, team_names: Option<Vec<String>>, ) -> Result<Application, VeracodeError>

Create application if it doesn’t exist, or return existing application.

This method implements the “check and create” pattern commonly needed for automated workflows.

§Arguments
  • name - The name of the application
  • business_criticality - Business criticality level (required for creation)
  • description - Optional description for new applications
  • team_names - Optional list of team names to assign to the application
§Returns

A Result containing the application (existing or newly created).

Source

pub async fn create_application_if_not_exists_with_team_guids( &self, name: &str, business_criticality: BusinessCriticality, description: Option<String>, team_guids: Option<Vec<String>>, ) -> Result<Application, VeracodeError>

Create application if it doesn’t exist, or return existing application (with team GUIDs).

This method allows specifying teams by their GUID, which is the preferred approach for programmatic application creation.

§Arguments
  • name - The name of the application
  • business_criticality - Business criticality level (required for creation)
  • description - Optional description for new applications
  • team_guids - Optional list of team GUIDs to assign to the application
§Returns

A Result containing the application (existing or newly created).

Source

pub async fn create_application_if_not_exists_simple( &self, name: &str, business_criticality: BusinessCriticality, description: Option<String>, ) -> Result<Application, VeracodeError>

Create application if it doesn’t exist, or return existing application (without teams).

This is a convenience method that maintains backward compatibility for callers that don’t need to specify teams.

§Arguments
  • name - The name of the application
  • business_criticality - Business criticality level (required for creation)
  • description - Optional description for new applications
§Returns

A Result containing the application (existing or newly created).

Source§

impl VeracodeClient

Source

pub fn new(config: VeracodeConfig) -> Result<Self, VeracodeError>

Create a new Veracode API client.

§Arguments
  • config - Configuration containing API credentials and settings
§Returns

A new VeracodeClient instance ready to make API calls.

Source

pub fn base_url(&self) -> &str

Get the base URL for API requests.

Source

pub fn config(&self) -> &VeracodeConfig

Get access to the configuration

Source

pub fn client(&self) -> &Client

Get access to the underlying reqwest client

Source

pub fn generate_auth_header( &self, method: &str, url: &str, ) -> Result<String, VeracodeError>

Generate authorization header for HMAC authentication

Source

pub async fn get( &self, endpoint: &str, query_params: Option<&[(String, String)]>, ) -> Result<Response, VeracodeError>

Make a GET request to the specified endpoint.

§Arguments
  • endpoint - The API endpoint path (e.g., “/appsec/v1/applications”)
  • query_params - Optional query parameters as key-value pairs
§Returns

A Result containing the HTTP response.

Source

pub async fn post<T: Serialize>( &self, endpoint: &str, body: Option<&T>, ) -> Result<Response, VeracodeError>

Make a POST request to the specified endpoint.

§Arguments
  • endpoint - The API endpoint path (e.g., “/appsec/v1/applications”)
  • body - Optional request body that implements Serialize
§Returns

A Result containing the HTTP response.

Source

pub async fn put<T: Serialize>( &self, endpoint: &str, body: Option<&T>, ) -> Result<Response, VeracodeError>

Make a PUT request to the specified endpoint.

§Arguments
  • endpoint - The API endpoint path (e.g., “/appsec/v1/applications/guid”)
  • body - Optional request body that implements Serialize
§Returns

A Result containing the HTTP response.

Source

pub async fn delete(&self, endpoint: &str) -> Result<Response, VeracodeError>

Make a DELETE request to the specified endpoint.

§Arguments
  • endpoint - The API endpoint path (e.g., “/appsec/v1/applications/guid”)
§Returns

A Result containing the HTTP response.

Source

pub async fn handle_response( response: Response, ) -> Result<Response, VeracodeError>

Helper method to handle common response processing.

Checks if the response is successful and returns an error if not.

§Arguments
  • response - The HTTP response to check
§Returns

A Result containing the response if successful, or an error if not.

Source

pub async fn get_with_query( &self, endpoint: &str, query_params: Option<Vec<(String, String)>>, ) -> Result<Response, VeracodeError>

Make a GET request with full URL construction and query parameter handling.

This is a higher-level method that builds the full URL and handles query parameters.

§Arguments
  • endpoint - The API endpoint path
  • query_params - Optional query parameters
§Returns

A Result containing the HTTP response, pre-processed for success/failure.

Source

pub async fn post_with_response<T: Serialize>( &self, endpoint: &str, body: Option<&T>, ) -> Result<Response, VeracodeError>

Make a POST request with automatic response handling.

§Arguments
  • endpoint - The API endpoint path
  • body - Optional request body
§Returns

A Result containing the HTTP response, pre-processed for success/failure.

Source

pub async fn put_with_response<T: Serialize>( &self, endpoint: &str, body: Option<&T>, ) -> Result<Response, VeracodeError>

Make a PUT request with automatic response handling.

§Arguments
  • endpoint - The API endpoint path
  • body - Optional request body
§Returns

A Result containing the HTTP response, pre-processed for success/failure.

Source

pub async fn delete_with_response( &self, endpoint: &str, ) -> Result<Response, VeracodeError>

Make a DELETE request with automatic response handling.

§Arguments
  • endpoint - The API endpoint path
§Returns

A Result containing the HTTP response, pre-processed for success/failure.

Source

pub async fn get_paginated( &self, endpoint: &str, base_query_params: Option<Vec<(String, String)>>, page_size: Option<u32>, ) -> Result<String, VeracodeError>

Make paginated GET requests to collect all results.

This method automatically handles pagination by making multiple requests and combining all results into a single response.

§Arguments
  • endpoint - The API endpoint path
  • base_query_params - Base query parameters (non-pagination)
  • page_size - Number of items per page (default: 500)
§Returns

A Result containing all paginated results as a single response body string.

Source

pub async fn get_with_params( &self, endpoint: &str, params: &[(&str, &str)], ) -> Result<Response, VeracodeError>

Make a GET request with query parameters

§Arguments
  • endpoint - The API endpoint to call
  • params - Query parameters as a slice of tuples
§Returns

A Result containing the response or an error.

Source

pub async fn post_form( &self, endpoint: &str, params: &[(&str, &str)], ) -> Result<Response, VeracodeError>

Make a POST request with form data

§Arguments
  • endpoint - The API endpoint to call
  • params - Form parameters as a slice of tuples
§Returns

A Result containing the response or an error.

Source

pub async fn upload_file_multipart( &self, endpoint: &str, params: HashMap<&str, &str>, file_field_name: &str, filename: &str, file_data: Vec<u8>, ) -> Result<Response, VeracodeError>

Upload a file using multipart form data

§Arguments
  • endpoint - The API endpoint to call
  • params - Additional form parameters
  • file_field_name - Name of the file field
  • filename - Name of the file
  • file_data - File data as bytes
§Returns

A Result containing the response or an error.

Source

pub async fn upload_file_multipart_put( &self, url: &str, file_field_name: &str, filename: &str, file_data: Vec<u8>, additional_headers: Option<HashMap<&str, &str>>, ) -> Result<Response, VeracodeError>

Upload a file using multipart form data with PUT method (for pipeline scans)

§Arguments
  • url - The full URL to upload to
  • file_field_name - Name of the file field
  • filename - Name of the file
  • file_data - File data as bytes
  • additional_headers - Additional headers to include
§Returns

A Result containing the response or an error.

Source

pub async fn upload_file_with_query_params( &self, endpoint: &str, query_params: &[(&str, &str)], file_field_name: &str, filename: &str, file_data: Vec<u8>, ) -> Result<Response, VeracodeError>

Upload a file with query parameters (like Java implementation)

This method mimics the Java API wrapper’s approach where parameters are added to the query string and the file is uploaded separately.

Memory optimization: Uses Cow for strings and Arc for file data to minimize cloning during retry attempts. Automatically retries on transient failures.

§Arguments
  • endpoint - The API endpoint to call
  • query_params - Query parameters as key-value pairs
  • file_field_name - Name of the file field
  • filename - Name of the file
  • file_data - File data as bytes
§Returns

A Result containing the response or an error.

Source

pub async fn post_with_query_params( &self, endpoint: &str, query_params: &[(&str, &str)], ) -> Result<Response, VeracodeError>

Make a POST request with query parameters (like Java implementation for XML API)

This method mimics the Java API wrapper’s approach for POST operations where parameters are added to the query string rather than form data.

§Arguments
  • endpoint - The API endpoint to call
  • query_params - Query parameters as key-value pairs
§Returns

A Result containing the response or an error.

Source

pub async fn get_with_query_params( &self, endpoint: &str, query_params: &[(&str, &str)], ) -> Result<Response, VeracodeError>

Make a GET request with query parameters (like Java implementation for XML API)

This method mimics the Java API wrapper’s approach for GET operations where parameters are added to the query string.

§Arguments
  • endpoint - The API endpoint to call
  • query_params - Query parameters as key-value pairs
§Returns

A Result containing the response or an error.

Source

pub async fn upload_large_file_chunked<F>( &self, endpoint: &str, query_params: &[(&str, &str)], file_path: &str, content_type: Option<&str>, progress_callback: Option<F>, ) -> Result<Response, VeracodeError>
where F: Fn(u64, u64, f64) + Send + Sync,

Upload a large file using chunked streaming (for uploadlargefile.do)

This method implements chunked upload functionality similar to the Java API wrapper. It uploads files in chunks and provides progress tracking capabilities.

§Arguments
  • endpoint - The API endpoint to call
  • query_params - Query parameters as key-value pairs
  • file_path - Path to the file to upload
  • content_type - Content type for the file (default: binary/octet-stream)
  • progress_callback - Optional callback for progress tracking
§Returns

A Result containing the response or an error.

Source

pub async fn upload_file_binary( &self, endpoint: &str, query_params: &[(&str, &str)], file_data: Vec<u8>, content_type: &str, ) -> Result<Response, VeracodeError>

Upload a file with binary data (optimized for uploadlargefile.do)

This method uploads a file as raw binary data without multipart encoding, which is the expected format for the uploadlargefile.do endpoint.

Memory optimization: Uses Arc for file data and Cow for strings to minimize allocations during retry attempts. Automatically retries on transient failures.

§Arguments
  • endpoint - The API endpoint to call
  • query_params - Query parameters as key-value pairs
  • file_data - File data as bytes
  • content_type - Content type for the file
§Returns

A Result containing the response or an error.

Source§

impl VeracodeClient

Source

pub fn applications_api(&self) -> &Self

Get an applications API instance. Uses REST API (api.veracode.*).

Source

pub fn sandbox_api(&self) -> SandboxApi<'_>

Get a sandbox API instance. Uses REST API (api.veracode.*).

Source

pub fn identity_api(&self) -> IdentityApi<'_>

Get an identity API instance. Uses REST API (api.veracode.*).

Source

pub fn pipeline_api(&self) -> PipelineApi

Get a pipeline scan API instance. Uses REST API (api.veracode.*).

Source

pub fn policy_api(&self) -> PolicyApi<'_>

Get a policy API instance. Uses REST API (api.veracode.*).

Source

pub fn findings_api(&self) -> FindingsApi

Get a findings API instance. Uses REST API (api.veracode.*).

Source

pub fn scan_api(&self) -> ScanApi

Get a scan API instance. Uses XML API (analysiscenter.veracode.*) for both sandbox and application scans.

Source

pub fn build_api(&self) -> BuildApi

Get a build API instance. Uses XML API (analysiscenter.veracode.*) for build management operations.

Source

pub fn workflow(&self) -> VeracodeWorkflow

Get a workflow helper instance. Provides high-level operations that combine multiple API calls.

Trait Implementations§

Source§

impl Clone for VeracodeClient

Source§

fn clone(&self) -> VeracodeClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

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

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

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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

impl<T> ErasedDestructor for T
where T: 'static,